Skip to content

Commit

Permalink
Merge pull request #5947 from henning-gerhardt/replace_size_by_isEmpty
Browse files Browse the repository at this point in the history
Replace size() comparison calls with isEmpty calls
  • Loading branch information
solth authored Feb 28, 2024
2 parents 6d0431a + f281dd4 commit 454ccde
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private void loadModulesIntoClasspath() {

// create a single URL class loader with all jars
// such that plugins can load classes from each other
if (jarsToBeAdded.size() > 0) {
if (!jarsToBeAdded.isEmpty()) {

for (URL url : jarsToBeAdded) {
logger.info("Loading module jar file from path " + url.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public DivXmlElementAccess() {
private boolean fileXmlElementAccessIsLinkedToChildren(FileXmlElementAccess fileXmlElementAccess,
List<DivType> divs,
Map<String, List<FileXmlElementAccess>> physicalDivisionsMap) {
if (divs.size() == 0) {
if (divs.isEmpty()) {
return false;
}
boolean test = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Map<String, Object> getJsonObject(Process process) {
jsonObject.put(ProcessTypeField.BATCHES.getKey(), addObjectRelation(process.getBatches(), true));
jsonObject.put(ProcessTypeField.COMMENTS.getKey(), addObjectRelation(process.getComments()));
jsonObject.put(ProcessTypeField.COMMENTS_MESSAGE.getKey(), getProcessComments(process));
jsonObject.put(ProcessTypeField.HAS_CHILDREN.getKey(), process.getChildren().size() > 0);
jsonObject.put(ProcessTypeField.HAS_CHILDREN.getKey(), !process.getChildren().isEmpty());
jsonObject.put(ProcessTypeField.PARENT_ID.getKey(), processParentId);
jsonObject.put(ProcessTypeField.TASKS.getKey(), addObjectRelation(process.getTasks(), true));
jsonObject.put(ProcessTypeField.METADATA.getKey(), process.getMetadata());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CommandResult runCommand(String script) throws IOException {

CommandResult commandResult = command.runCommand(script);
List<String> commandResultMessages = commandResult.getMessages();
if (commandResultMessages.size() > 0 && commandResultMessages.get(0).contains("IOException")) {
if (!commandResultMessages.isEmpty() && commandResultMessages.get(0).contains("IOException")) {
throw new IOException(commandResultMessages.get(1));
}
return commandResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public void removeBlock(Block block) {
if (index > 0) {
index--;
}
if (course.size() > 0) {
if (!course.isEmpty()) {
navigate(course.get(index));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public List<Process> getSelectedProcesses() {
logger.error(e.getMessage());
}
}
if (selectedProcessesOrProcessDTOs.size() > 0) {
if (!selectedProcessesOrProcessDTOs.isEmpty()) {
if (selectedProcessesOrProcessDTOs.get(0) instanceof ProcessDTO) {
// list contains ProcessDTO instances
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void handleFileUpload(FileUploadEvent event) {
}
}

if (createProcessForm.getProcesses().size() > 0 && additionalImport) {
if (!createProcessForm.getProcesses().isEmpty() && additionalImport) {
extendsMetadataTableOfMetadataTab(processes);
} else {
this.createProcessForm.setProcesses(processes);
Expand All @@ -116,7 +116,7 @@ private TempProcess extractParentRecordFromFile(UploadedFile uploadedFile, Docum
Collection<String> higherLevelIdentifier = this.createProcessForm.getRulesetManagement()
.getFunctionalKeys(FunctionalMetadata.HIGHERLEVEL_IDENTIFIER);

if (higherLevelIdentifier.size() > 0) {
if (!higherLevelIdentifier.isEmpty()) {
ImportService importService = ServiceManager.getImportService();
String parentID = importService.getParentID(internalDocument, higherLevelIdentifier.toArray()[0].toString(),
importConfiguration.getParentElementTrimMode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void createInsertionPositionSelectionTree() throws DAOException, DataExce
priorityList);
logicalStructure.setExpanded(true);

if (selectableInsertionPositions.size() > 0) {
if (!selectableInsertionPositions.isEmpty()) {
selectedInsertionPosition = (String) ((LinkedList<SelectItem>) selectableInsertionPositions).getLast()
.getValue();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void addDocStruc(boolean preview) {
}
if (preview && (!(StringUtils.isEmpty(selectFirstPageOnAddNode)
|| StringUtils.isEmpty(this.selectLastPageOnAddNode))
|| Objects.nonNull(this.preselectedViews) && this.preselectedViews.size() > 0)) {
|| Objects.nonNull(this.preselectedViews) && !this.preselectedViews.isEmpty())) {
dataEditor.getGalleryPanel().setGalleryViewMode(PREVIEW_MODE);
} else {
dataEditor.getGalleryPanel().setGalleryViewMode(LIST_MODE);
Expand Down Expand Up @@ -393,7 +393,7 @@ public List<SelectItem> getSelectPageOnAddNodeItems() {
}

private List<View> getViewsToAdd() {
if (Objects.nonNull(preselectedViews) && preselectedViews.size() > 0) {
if (Objects.nonNull(preselectedViews) && !preselectedViews.isEmpty()) {
return preselectedViews;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void preparePossiblePositions() {
Helper.getTranslation("dataEditor.position.asLastChildOfCurrentElement")));
List<PhysicalDivision> parents = MetadataEditor.getAncestorsOfPhysicalDivision(selectedPhysicalDivision.get(),
dataEditor.getWorkpiece().getPhysicalStructure());
if (parents.size() > 0) {
if (!parents.isEmpty()) {
possiblePositions.add(new SelectItem(InsertionPosition.BEFORE_CURRENT_ELEMENT,
Helper.getTranslation("dataEditor.position.beforeCurrentElement")));
possiblePositions.add(new SelectItem(InsertionPosition.AFTER_CURRENT_ELEMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public String getGalleryViewMode() {
* @return value of lastSelection
*/
public Pair<PhysicalDivision, LogicalDivision> getLastSelection() {
if (dataEditor.getSelectedMedia().size() > 0) {
if (!dataEditor.getSelectedMedia().isEmpty()) {
return dataEditor.getSelectedMedia().get(dataEditor.getSelectedMedia().size() - 1);
} else if (dataEditor.getSelectedStructure().isPresent()
&& !dataEditor.getSelectedStructure().get().getViews().isEmpty()) {
Expand All @@ -148,7 +148,7 @@ public Pair<PhysicalDivision, LogicalDivision> getLastSelection() {
* @return boolean
*/
public boolean isLastSelection(GalleryMediaContent galleryMediaContent, GalleryStripe galleryStripe) {
if (isSelected(galleryMediaContent, galleryStripe) && dataEditor.getSelectedMedia().size() > 0
if (isSelected(galleryMediaContent, galleryStripe) && !dataEditor.getSelectedMedia().isEmpty()
&& Objects.nonNull(galleryMediaContent)) {
return Objects.equals(galleryMediaContent.getView().getPhysicalDivision(),
dataEditor.getSelectedMedia().get(dataEditor.getSelectedMedia().size() - 1).getKey());
Expand Down Expand Up @@ -337,7 +337,7 @@ private void updateStructure(GalleryMediaContent galleryMediaContent, LogicalDiv
}

void updateSelection(PhysicalDivision physicalDivision, LogicalDivision structuralElement) {
if (physicalDivision.getMediaFiles().size() > 0) {
if (!physicalDivision.getMediaFiles().isEmpty()) {

// Update structured view
if (this.galleryViewMode.equals(GalleryViewMode.LIST)) {
Expand Down Expand Up @@ -708,7 +708,7 @@ private List<Pair<PhysicalDivision, LogicalDivision>> getMediaWithinRangeFromSel
countDown = true;
}

if (galleryStripes.size() == 0) {
if (galleryStripes.isEmpty()) {
return new LinkedList<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ void reorderPhysicalDivisions(LogicalDivision toElement,
insertionIndex = -1;
}

if (insertionIndex < 0 || toElement.getViews().size() == 0) {
if (insertionIndex < 0 || toElement.getViews().isEmpty()) {
// no insertion position was specified or the element does not contain any pages yet
physicalInsertionIndex = toElement.getOrder() - 1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private static String getTitleFromWorkpiece(Process process) {
private static String getTitleFromParents(List<TempProcess> parentTempProcesses,
RulesetManagementInterface rulesetManagement, String acquisitionStage,
List<Locale.LanguageRange> priorityList) {
if (parentTempProcesses.size() == 0) {
if (parentTempProcesses.isEmpty()) {
return StringUtils.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ public boolean searchForMedia(Process process, Workpiece workpiece)
List<String> canonicals = getCanonicalFileNamePartsAndSanitizeAbsoluteURIs(workpiece, subfolders,
process.getProcessBaseUri());

if (currentMedia.size() == 0 && canonicals.size() > 0) {
if (currentMedia.isEmpty() && !canonicals.isEmpty()) {
throw new MediaNotFoundException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void filterByProject() {
*/
public String getFirstSearchResultProcessTitle() {
List<String> tableDataByColumn = getTableDataByColumn(searchResultTable, 3);
if (tableDataByColumn.size() == 0 || tableDataByColumn.contains("No records found.")) {
if (tableDataByColumn.isEmpty() || tableDataByColumn.contains("No records found.")) {
return null;
}
return tableDataByColumn.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void clickTaskTableColumnHeaderForSorting(int column) {
*/
public String getFirstRowTaskTitle() {
List<String> taskTitles = getTableDataByColumn(taskTable, 1);
if (taskTitles.size() > 0) {
if (!taskTitles.isEmpty()) {
return taskTitles.get(0);
}
return "";
Expand Down

0 comments on commit 454ccde

Please sign in to comment.