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;
}
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;
}
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;
}
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;
}
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());
}
Aggregations