Search in sources :

Example 1 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class JavaRefactoringRename method createRenameRefactoringDto.

@NotNull
private CreateRenameRefactoring createRenameRefactoringDto(TextEditor editor, boolean isActiveLinkedMode) {
    CreateRenameRefactoring dto = dtoFactory.createDto(CreateRenameRefactoring.class);
    dto.setOffset(editor.getCursorOffset());
    dto.setRefactorLightweight(isActiveLinkedMode);
    final VirtualFile file = editor.getEditorInput().getFile();
    dto.setPath(JavaUtil.resolveFQN(file));
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        dto.setProjectPath(project.get().getLocation().toString());
    }
    dto.setType(JAVA_ELEMENT);
    return dto;
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Project(org.eclipse.che.ide.api.resources.Project) Resource(org.eclipse.che.ide.api.resources.Resource) CreateRenameRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring) NotNull(javax.validation.constraints.NotNull)

Example 2 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class JavaRefactoringRename method createLinkedRenameRefactoringApplyDto.

@NotNull
private LinkedRenameRefactoringApply createLinkedRenameRefactoringApplyDto(String newName, String sessionId) {
    LinkedRenameRefactoringApply dto = dtoFactory.createDto(LinkedRenameRefactoringApply.class);
    dto.setNewName(newName);
    dto.setSessionId(sessionId);
    return dto;
}
Also used : LinkedRenameRefactoringApply(org.eclipse.che.ide.ext.java.shared.dto.refactoring.LinkedRenameRefactoringApply) NotNull(javax.validation.constraints.NotNull)

Example 3 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class NameGenerator method generateCopy.

/**
     * @return recipe name which consists of string 'Copy of ' and existing name with a current date. If there is an existing name,
     * add a number suffix like "Copy2 of", "Copy3 of", etc.
     */
@NotNull
public static String generateCopy(@NotNull String name, @NotNull Set<RecipeWidget> recipeWidgets) {
    List<String> existingNames = new ArrayList<>();
    for (RecipeWidget recipe : recipeWidgets) {
        existingNames.add(recipe.getDescriptor().getName());
    }
    name = removeCopyPrefix(name);
    name = name.replace("+", "");
    String copyName = "Copy of ".concat(name);
    boolean alreadyExists = existingNames.contains(copyName);
    int index = 2;
    while (alreadyExists) {
        copyName = "Copy".concat(String.valueOf(index)).concat(" of ").concat(name);
        alreadyExists = existingNames.contains(copyName);
        index++;
    }
    return copyName;
}
Also used : ArrayList(java.util.ArrayList) RecipeWidget(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.entry.RecipeWidget) NotNull(javax.validation.constraints.NotNull)

Example 4 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class RecipePartPresenter method addRecipe.

/**
     * Adds new recipe to list.
     *
     * @param recipeDescriptor
     *         a descriptor of new recipe
     */
@NotNull
private RecipeWidget addRecipe(@NotNull RecipeDescriptor recipeDescriptor) {
    RecipeWidget recipe = new RecipeWidget(recipeDescriptor, resources);
    recipe.setDelegate(this);
    view.addRecipe(recipe);
    recipesContainerPresenter.addRecipePanel(recipe);
    recipes.put(recipe, recipeDescriptor);
    return recipe;
}
Also used : RecipeWidget(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.entry.RecipeWidget) NotNull(javax.validation.constraints.NotNull)

Example 5 with NotNull

use of javax.validation.constraints.NotNull in project druid by druid-io.

the class ExceptionalAbstractListenerHandler method testAbstractPostHandler.

@Test
public // Take a list of strings wrap them in a JSON POJO and get them back as an array string in the POST function
void testAbstractPostHandler() throws Exception {
    final AbstractListenerHandler handler = new ExceptionalAbstractListenerHandler() {

        @Nullable
        @Override
        public String post(@NotNull Map<String, SomeBeanClass> inputObject) throws Exception {
            return mapper.writeValueAsString(inputObject);
        }
    };
    final ListenerResource resource = new ListenerResource(mapper, mapper, handler) {
    };
    final List<String> strings = ImmutableList.of("test1", "test2");
    final Map<String, SomeBeanClass> expectedMap = new HashMap<>();
    for (final String str : strings) {
        expectedMap.put(str, new SomeBeanClass(str));
    }
    final String expectedString = mapper.writeValueAsString(expectedMap);
    final Response response = resource.serviceAnnouncementPOSTAll(new ByteArrayInputStream(StringUtils.toUtf8(expectedString)), req);
    Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus());
    Assert.assertEquals(expectedString, response.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) NotNull(javax.validation.constraints.NotNull) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

NotNull (javax.validation.constraints.NotNull)74 List (java.util.List)23 Map (java.util.Map)17 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)14 ArrayList (java.util.ArrayList)13 LoggerFactory (org.slf4j.LoggerFactory)13 HashMap (java.util.HashMap)11 Set (java.util.Set)10 Optional (java.util.Optional)9 Response (javax.ws.rs.core.Response)9 Strings (com.google.common.base.Strings)8 Lists (com.google.common.collect.Lists)8 Api (io.swagger.annotations.Api)7 ApiParam (io.swagger.annotations.ApiParam)7 Collection (java.util.Collection)7 Nullable (javax.annotation.Nullable)7 Component (org.springframework.stereotype.Component)7 Valid (javax.validation.Valid)6