Browse Source

Use isEmpty() instead of size()==0 where possible

Change-Id: I97f1367a2ea9f1f6146e264c27c3981b842f2a26
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.4
Carsten Hammer 6 years ago committed by Matthias Sohn
parent
commit
6a4c77e619
  1. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java
  2. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java
  3. 9
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
  5. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java
  6. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
  7. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
  8. 2
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
  9. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
  10. 2
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
  11. 2
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
  12. 2
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
  13. 3
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java

@ -96,7 +96,7 @@ public class PathTreeFilterHandler extends OptionHandler<TreeFilter> {
filters.add(PathFilter.create(path));
}
if (filters.size() == 0)
if (filters.isEmpty())
return 0;
if (filters.size() == 1) {
setter.addValue(filters.get(0));

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java

@ -128,7 +128,7 @@ public class CleanCommandTest extends RepositoryTestCase {
status = git.status().call();
files = status.getUntracked();
assertTrue(files.size() == 0);
assertTrue(files.isEmpty());
assertTrue(cleanedFiles.contains("File2.txt"));
assertTrue(cleanedFiles.contains("File3.txt"));
assertTrue(!cleanedFiles.contains("sub-noclean/File1.txt"));

9
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java

@ -45,7 +45,6 @@
package org.eclipse.jgit.lib;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -63,7 +62,8 @@ public class ReflogConfigTest extends RepositoryTestCase {
// check that there are no entries in the reflog and turn off writing
// reflogs
assertEquals(0, db.getReflogReader(Constants.HEAD).getReverseEntries().size());
assertTrue(db.getReflogReader(Constants.HEAD).getReverseEntries()
.isEmpty());
final FileBasedConfig cfg = db.getConfig();
cfg.setBoolean("core", null, "logallrefupdates", false);
cfg.save();
@ -72,9 +72,8 @@ public class ReflogConfigTest extends RepositoryTestCase {
// written
commit("A Commit\n", commitTime, tz);
commitTime += 60 * 1000;
assertTrue(
"Reflog for HEAD still contain no entry",
db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 0);
assertTrue("Reflog for HEAD still contain no entry", db
.getReflogReader(Constants.HEAD).getReverseEntries().isEmpty());
// set the logAllRefUpdates parameter to true and check it
cfg.setBoolean("core", null, "logallrefupdates", true);

2
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

@ -282,7 +282,7 @@ public class CommitCommand extends GitCommand<RevCommit> {
ru.setRefLogMessage(reflogComment, false);
} else {
String prefix = amend ? "commit (amend): " //$NON-NLS-1$
: parents.size() == 0 ? "commit (initial): " //$NON-NLS-1$
: parents.isEmpty() ? "commit (initial): " //$NON-NLS-1$
: "commit: "; //$NON-NLS-1$
ru.setRefLogMessage(prefix + revCommit.getShortMessage(),
false);

4
org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java

@ -246,9 +246,9 @@ public class DescribeCommand extends GitCommand<String> {
};
private Optional<Ref> getBestMatch(List<Ref> tags) {
if (tags == null || tags.size() == 0) {
if (tags == null || tags.isEmpty()) {
return Optional.empty();
} else if (matchers.size() == 0) {
} else if (matchers.isEmpty()) {
Collections.sort(tags, TAG_TIE_BREAKER);
return Optional.of(tags.get(0));
} else {

2
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java

@ -362,7 +362,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
List<RebaseTodoLine> steps = repo.readRebaseTodo(
rebaseState.getPath(GIT_REBASE_TODO), false);
if (steps.size() == 0) {
if (steps.isEmpty()) {
return finishRebase(walk.parseCommit(repo.resolve(Constants.HEAD)), false);
}
if (isInteractive()) {

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java

@ -1063,7 +1063,7 @@ public class DiffFormatter implements AutoCloseable {
entry.newId = id;
break;
}
} else if (ids.size() == 0)
} else if (ids.isEmpty())
throw new MissingObjectException(id, Constants.OBJ_BLOB);
else
throw new AmbiguousObjectException(id, ids);

2
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java vendored

@ -632,7 +632,7 @@ public class DirCacheCheckout {
if (!builder.commit())
throw new IndexWriteException();
}
return toBeDeleted.size() == 0;
return toBeDeleted.isEmpty();
}
private void checkoutGitlink(String path, DirCacheEntry entry)

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

@ -745,7 +745,7 @@ public class RefDirectory extends RefDatabase {
for (LockFile ol : heldLocks.values()) {
ol.requireLock();
}
if (refs.size() == 0) {
if (refs.isEmpty()) {
return null;
}
FS fs = parent.getFS();

2
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -923,7 +923,7 @@ public abstract class Repository implements AutoCloseable {
AbbreviatedObjectId id = AbbreviatedObjectId.fromString(revstr);
try (ObjectReader reader = newObjectReader()) {
Collection<ObjectId> matches = reader.resolve(id);
if (matches.size() == 0)
if (matches.isEmpty())
return null;
else if (matches.size() == 1)
return matches.iterator().next();

2
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

@ -1179,7 +1179,7 @@ public class ResolveMerger extends ThreeWayMerger {
* fail.
*/
public Map<String, MergeFailureReason> getFailingPaths() {
return (failingPaths.size() == 0) ? null : failingPaths;
return failingPaths.isEmpty() ? null : failingPaths;
}
/**

2
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java

@ -506,7 +506,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
if (sorting.size() > 1)
sorting.remove(RevSort.NONE);
else if (sorting.size() == 0)
else if (sorting.isEmpty())
sorting.add(RevSort.NONE);
}

3
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java

@ -229,8 +229,9 @@ public class BundleWriter {
packWriter.setDeltaBaseAsOffset(true);
packWriter.setThin(exc.size() > 0);
packWriter.setReuseValidatingObjects(false);
if (exc.size() == 0)
if (exc.isEmpty()) {
packWriter.setTagTargets(tagTargets);
}
packWriter.preparePack(monitor, inc, exc);
final Writer w = new OutputStreamWriter(os, UTF_8);

Loading…
Cancel
Save