Skip to content

Commit

Permalink
sonarlint :: Use isEmpty() to check if collection is empty or not (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfkoehler authored Oct 23, 2024
1 parent 0764642 commit 7f036c5
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/main/java/emissary/core/HDMobileAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ protected void agentControl(final IServiceProviderPlace currentPlaceArg) {
final List<IBaseDataObject> sprouts = atPlaceHD(currentPlace, toBeProcessed);

// Add any sprouts collected from the payloads
if (sprouts.size() > 0) {
if (!sprouts.isEmpty()) {
addPayload(sprouts);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/directory/DirectoryEntryMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected DirectoryEntry removeEntry(final String key, final String entryKey) {
}

// Remove the mapping if it is empty
if (list.size() == 0) {
if (list.isEmpty()) {
this.remove(key);
}
}
Expand Down Expand Up @@ -391,7 +391,7 @@ public List<String> addCostToMatching(final String key, final int increment) {
}

// Put them back in order if something changed
if (ret.size() > 0) {
if (!ret.isEmpty()) {
sort();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static Document buildProxyDocument(final IRemoteDirectory dir, final Stri
}

// Add them to the xml
if (list.size() > 0) {
if (!list.isEmpty()) {
final Element listEl = list.getXml();
listEl.setAttribute(DATAID_ATTR, dataId);
root.addContent(listEl);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/parser/SessionProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public IBaseDataObject createAndLoadDataObject(DecomposedSession session, String
IBaseDataObject dataObject = DataObjectFactory.getInstance(new Object[] {theData, sName});

// Pop default form if we have something to say
if (initialForms != null && initialForms.size() > 0) {
if (initialForms != null && !initialForms.isEmpty()) {
dataObject.popCurrentForm();
// Add our stuff to the form stack
for (int j = initialForms.size() - 1; j >= 0; j--) {
Expand All @@ -77,7 +77,7 @@ public IBaseDataObject createAndLoadDataObject(DecomposedSession session, String
}

List<String> sessionForms = session.getInitialForms();
if (sessionForms != null && sessionForms.size() > 0) {
if (sessionForms != null && !sessionForms.isEmpty()) {
dataObject.popCurrentForm();
for (int j = sessionForms.size() - 1; j >= 0; j--) {
dataObject.pushCurrentForm(sessionForms.get(j));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/pickup/PickUpPlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected void configurePickUpPlace() {
logger.debug("Pickup Canonical HOLD => {}, Pickup Canonical DONE => {}, Pickup Canonical ERROR => {}", holdingArea, doneArea, errorArea);

initialFormValues = configG.findEntries("INITIAL_FORM");
if (initialFormValues.size() < 1) {
if (initialFormValues.isEmpty()) {
initialFormValues.add(Form.UNKNOWN);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/pickup/PickUpSpace.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void closeSpace(String spaceName) {
@Override
@Nullable
public String getSpaceName() {
if (openSpaceNames.size() > 0) {
if (!openSpaceNames.isEmpty()) {
return openSpaceNames.get(0);
} else {
return null;
Expand Down Expand Up @@ -141,7 +141,7 @@ public int getSpaceCount() {
*/
@Override
public boolean take() {
if (openSpaceNames.size() == 0) {
if (openSpaceNames.isEmpty()) {
logger.debug("Cannot perform 'take' when no spaces are available");
return false;
}
Expand Down Expand Up @@ -200,7 +200,7 @@ protected void cleanupFailedSpaces(List<String> forceClosers) {
closeSpace(s);
}

if (closers.size() > 0) {
if (!closers.isEmpty()) {
logger.debug("Cleaned up " + closers.size() + " workspace instances, " + openSpaceNames.size() + " remaining");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/pool/MoveSpool.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void resetPool() {
public void quit() {
logger.warn("Purging the spool...");
synchronized (spool) {
if (spool.size() > 0) {
if (!spool.isEmpty()) {
spool.clear();
}
spool.notifyAll();
Expand Down Expand Up @@ -157,7 +157,7 @@ public void run() {
logger.debug("Nothing in spool, time to wait...");
Thread.yield();
synchronized (spool) {
if (spool.size() == 0) {
if (spool.isEmpty()) {
spool.wait(60000);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/util/magic/MagicNumberFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static List<MagicNumber> buildMagicNumberList(byte[] configData, @Nullabl
continue;
}
try {
if (depth == 0 && extensions.size() > 0) {
if (depth == 0 && !extensions.isEmpty()) {
if (finger == null) {
extensions = null;
extensions = new ArrayList<>();
Expand Down Expand Up @@ -111,7 +111,7 @@ public static List<MagicNumber> buildMagicNumberList(byte[] configData, @Nullabl
if (currentDepth == depth) {
parseAndStore(extensions, s, swallowParseException);
} else if (currentDepth < depth) {
if (extensions.size() == 0) {
if (extensions.isEmpty()) {
finger = null;
currentDepth = -1;
continue;
Expand Down Expand Up @@ -150,7 +150,7 @@ public static List<MagicNumber> buildMagicNumberList(byte[] configData, @Nullabl
}
}
}
if (finger != null && extensions.size() > 0) {
if (finger != null && !extensions.isEmpty()) {
addExtensionsLayer(extensions, finger);
}
} catch (IOException ioe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public HitList findNext(final byte[] dataArg, final int start, final int stop) {
for (position = start + this.standardSkip - 1; position < stop; position += this.skipTable[get256Value(dataArg[position])]) {
try {
this.treeScanner.scan(dataArg, position, hits);
if (hits.size() > 0) {
if (!hits.isEmpty()) {
break;
}
} catch (Exception e) {
Expand Down

0 comments on commit 7f036c5

Please sign in to comment.