Skip to content

Commit f85ef18

Browse files
committed
[Misc] Use Collection.isEmpty() instead of size() > 0 / size() === 0
1 parent 32d7b06 commit f85ef18

87 files changed

Lines changed: 141 additions & 143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-test/xwiki-platform-administration-test-pageobjects/src/main/java/org/xwiki/administration/test/po/AdministrationMenu.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public boolean hasCategoryWithName(String categoryName)
8282

8383
public boolean hasNotCategoryWithId(String categoryId)
8484
{
85-
return getDriver().findElementsWithoutWaiting(this.container, categoryById(categoryId)).size() == 0;
85+
return getDriver().findElementsWithoutWaiting(this.container, categoryById(categoryId)).isEmpty();
8686
}
8787

8888
public boolean hasNotCategoryWithName(String categoryName)
8989
{
90-
return getDriver().findElementsWithoutWaiting(this.container, categoryByName(categoryName)).size() == 0;
90+
return getDriver().findElementsWithoutWaiting(this.container, categoryByName(categoryName)).isEmpty();
9191
}
9292

9393
public AdministrationMenu expandCategoryWithId(String categoryId)
@@ -143,13 +143,13 @@ public boolean hasSectionWithName(String categoryName, String sectionName)
143143

144144
public boolean hasNotSectionWithId(String sectionId)
145145
{
146-
return getDriver().findElementsWithoutWaiting(this.container, sectionById(sectionId)).size() == 0;
146+
return getDriver().findElementsWithoutWaiting(this.container, sectionById(sectionId)).isEmpty();
147147
}
148148

149149
public boolean hasNotSectionWithName(String categoryName, String sectionName)
150150
{
151151
return getDriver().findElementsWithoutWaiting(this.container, sectionByName(categoryName, sectionName))
152-
.size() == 0;
152+
.isEmpty();
153153
}
154154

155155
/**

xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-test/xwiki-platform-administration-test-pageobjects/src/main/java/org/xwiki/administration/test/po/RegistrationModal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ public boolean validationFailureMessagesInclude(String message)
7070
By serverSideErrorMessage =
7171
By.xpath(String.format("//div[contains(@class,'xnotification-error') and contains(., '%s')]", message));
7272
return super.validationFailureMessagesInclude(message)
73-
|| getDriver().findElementsWithoutWaiting(serverSideErrorMessage).size() > 0;
73+
|| !getDriver().findElementsWithoutWaiting(serverSideErrorMessage).isEmpty();
7474
}
7575
}

xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-core/src/main/java/org/xwiki/annotation/internal/renderer/AnnotationGeneratorChainingListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ protected void addAnnotationEvent(AnnotationEvent evt, List<AnnotationEvent> lis
323323
{
324324
// if there is no event in the list, or the event is a start event or there is no start event in the list, just
325325
// append the event to the end of the list
326-
if (list.size() == 0 || evt.getType() == AnnotationEventType.START
326+
if (list.isEmpty() || evt.getType() == AnnotationEventType.START
327327
|| list.get(list.size() - 1).getType() == AnnotationEventType.END) {
328328
list.add(evt);
329329
} else {

xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-maintainer/src/main/java/org/xwiki/annotation/maintainer/AbstractAnnotationMaintainer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void updateAnnotations(String target, String previousContent, String curr
8989
try {
9090
annotations = ioService.getAnnotations(target);
9191

92-
if (annotations.size() == 0) {
92+
if (annotations.isEmpty()) {
9393
// no annotations, nothing to do
9494
return;
9595
}
@@ -107,7 +107,7 @@ public void updateAnnotations(String target, String previousContent, String curr
107107
getDiffService().getDifferences(renderedPreviousContent, renderedCurrentContent);
108108
// if any differences: note that there can be updates on the content that have no influence on the plain
109109
// text space normalized version
110-
if (differences.size() > 0) {
110+
if (!differences.isEmpty()) {
111111
// compute the spaceless version of the renderedPreviousContent to be able to map the annotation on it
112112
// (so that matching is done in the same way as for rendering), and then go back to the normalized
113113
// version
@@ -329,7 +329,7 @@ private void ensureUnique(Annotation annotation, String content, int cStart, int
329329
{
330330
// find out if there is another encounter of the selection text & context than the one at cStart
331331
List<Integer> occurrences = getOccurrences(content, annotation.getSelectionInContext(), cStart);
332-
if (occurrences.size() == 0) {
332+
if (occurrences.isEmpty()) {
333333
// it appears only once, it's done
334334
return;
335335
}

xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-test/xwiki-platform-annotation-test-pageobjects/src/main/java/org/xwiki/annotation/test/po/AnnotatableViewPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public void selectText(String annotationWord)
286286

287287
public boolean checkIfAnnotationsAreDisabled()
288288
{
289-
if (getDriver().findElementsWithoutWaiting(By.id("annotationsdisplay")).size() > 0) {
289+
if (!getDriver().findElementsWithoutWaiting(By.id("annotationsdisplay")).isEmpty()) {
290290
return false;
291291
} else {
292292
return true;

xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-test/xwiki-platform-annotation-test-pageobjects/src/main/java/org/xwiki/annotation/test/po/AnnotationsPane.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void clickHideAnnotations()
112112
*/
113113
public boolean checkIfShowAnnotationsCheckboxExists()
114114
{
115-
if (getDriver().findElementsWithoutWaiting(By.id("annotationsdisplay")).size() > 0) {
115+
if (!getDriver().findElementsWithoutWaiting(By.id("annotationsdisplay")).isEmpty()) {
116116
return true;
117117
} else {
118118
return false;

xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-test/xwiki-platform-appwithinminutes-test-pageobjects/src/main/java/org/xwiki/appwithinminutes/test/po/ApplicationClassEditPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public ApplicationCreatePage clickPreviousStep()
9595
*/
9696
public boolean hasPreviousStep()
9797
{
98-
return getDriver().findElementsWithoutWaiting(By.linkText("Previous Step")).size() > 0;
98+
return !getDriver().findElementsWithoutWaiting(By.linkText("Previous Step")).isEmpty();
9999
}
100100

101101
/**

xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-test/xwiki-platform-appwithinminutes-test-pageobjects/src/main/java/org/xwiki/appwithinminutes/test/po/ApplicationHomeEditPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public boolean hasLiveTableColumn(String columnLabel)
213213
{
214214
String escapedColumnLabel = columnLabel.replace("\\", "\\\\").replace("'", "\\'");
215215
String xpath = "//ul[@class = 'hList']/li[starts-with(., '" + escapedColumnLabel + "')]";
216-
return getDriver().findElementsWithoutWaiting(getForm(), By.xpath(xpath)).size() > 0;
216+
return !getDriver().findElementsWithoutWaiting(getForm(), By.xpath(xpath)).isEmpty();
217217
}
218218

219219
/**

xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-test/xwiki-platform-appwithinminutes-test-pageobjects/src/main/java/org/xwiki/appwithinminutes/test/po/ApplicationHomePage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public LiveTableElement getEntriesLiveTable()
107107
*/
108108
public boolean hasEntriesLiveTable()
109109
{
110-
return getDriver().findElements(By.className("xwiki-livetable")).size() > 0;
110+
return !getDriver().findElements(By.className("xwiki-livetable")).isEmpty();
111111
}
112112

113113
public ConfirmationPage clickDeleteAllEntries()

xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-test/xwiki-platform-appwithinminutes-test-pageobjects/src/main/java/org/xwiki/appwithinminutes/test/po/ApplicationTemplateProviderEditPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public String getTerminal()
132132

133133
public boolean hasTerminalOption()
134134
{
135-
return getDriver().findElementsWithoutWaiting(By.cssSelector("select#XWiki\\.TemplateProviderClass_0_terminal"))
136-
.size() > 0;
135+
return !getDriver()
136+
.findElementsWithoutWaiting(By.cssSelector("select#XWiki\\.TemplateProviderClass_0_terminal")).isEmpty();
137137
}
138138
}

0 commit comments

Comments
 (0)