diff options
author | Carsten Hammer <carsten.hammer@t-online.de> | 2019-04-11 19:27:34 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-04-13 19:53:29 +0200 |
commit | 6a4c77e619d79c885aa6f08f2a1d8d8c1a936bcb (patch) | |
tree | 30c8ad7fa8a890578c07026d494cacb4a16406a7 /org.eclipse.jgit | |
parent | 6e03645ad80adf71527ca18f937db4b8e34b7f13 (diff) | |
download | jgit-6a4c77e619d79c885aa6f08f2a1d8d8c1a936bcb.tar.gz jgit-6a4c77e619d79c885aa6f08f2a1d8d8c1a936bcb.zip |
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>
Diffstat (limited to 'org.eclipse.jgit')
10 files changed, 12 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index 9f071c4c4e..8671800df2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/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); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java index c7b2c35491..831865a2db 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java +++ b/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 { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java index 9be4c916ba..cdd1b80bb4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/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()) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java index e7ad0bc40d..1cecff6fb0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java +++ b/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); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java index 307fd3f310..a3dbc50a78 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java @@ -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) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index 35aca086bf..e5cea6c010 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/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(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index 30f247b83a..b242f98ef7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/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(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index 9ea1868ebb..b69327a9b3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/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; } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java index 0a43e8fb1a..f12eb2ff86 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java +++ b/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); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java index 56aaede80d..a09b1ff1d2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java +++ b/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); |