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>
tags/v5.4.0.201905081430-m2
Carsten Hammer 5 years ago
parent
commit
6a4c77e619

+ 1
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java View File

@@ -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));

+ 1
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java View File

@@ -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"));

+ 4
- 5
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java View File

@@ -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);

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java View File

@@ -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);

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java View File

@@ -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 {

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java View File

@@ -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()) {

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java View File

@@ -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);

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java View File

@@ -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)

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java View File

@@ -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();

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java View File

@@ -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();

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java View File

@@ -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;
}

/**

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java View File

@@ -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);
}


+ 2
- 1
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java View File

@@ -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