Fix more cases where Collection.isEmpty() should be used

Change-Id: I9c8465445373179f928f33e57dae83c9027b7a9f
This commit is contained in:
David Pursehouse
2020-02-19 23:05:04 +09:00
parent e109b86d31
commit d305f84d90
5 changed files with 6 additions and 6 deletions

View File

@@ -69,7 +69,7 @@ public class Section {
all.addAll(Arrays.asList(flags.cfg.getStringList(section, subsection, name)));
if (value != null) {
if (all.size() == 0 || all.size() == 1) {
if (all.isEmpty() || all.size() == 1) {
flags.cfg.setString(section, subsection, name, value);
} else {
all.set(0, value);
@@ -78,7 +78,7 @@ public class Section {
} else if (all.size() == 1) {
flags.cfg.unset(section, subsection, name);
} else if (all.size() != 0) {
} else if (!all.isEmpty()) {
all.remove(0);
flags.cfg.setStringList(section, subsection, name, all);
}

View File

@@ -167,7 +167,7 @@ public class GroupCollector {
checkState(!done, "visit() called after getGroups()");
Set<RevCommit> interestingParents = getInterestingParents(c);
if (interestingParents.size() == 0) {
if (interestingParents.isEmpty()) {
// All parents are uninteresting: treat this commit as the root of a new
// group of related changes.
groups.put(c, c.name());

View File

@@ -2159,7 +2159,7 @@ class ReceiveCommits {
return Collections.emptyList();
}
if (changes.size() == 0) {
if (changes.isEmpty()) {
if (!isValidChangeId(p.changeKey.get())) {
reject(magicBranch.cmd, "invalid Change-Id");
return Collections.emptyList();

View File

@@ -72,7 +72,7 @@ public class DeleteExternalIds implements RestModifyView<AccountResource, List<S
permissionBackend.currentUser().check(GlobalPermission.ACCESS_DATABASE);
}
if (extIds == null || extIds.size() == 0) {
if (extIds == null || extIds.isEmpty()) {
throw new BadRequestException("external IDs are required");
}

View File

@@ -238,7 +238,7 @@ public class ReviewerRecommender {
// (weighted 10d), number of comments (weighted 0.5d) and number of owned
// changes (weighted 1d).
Map<Account.Id, MutableDouble> reviewers = new LinkedHashMap<>();
if (candidates.size() == 0) {
if (candidates.isEmpty()) {
return reviewers;
}
List<Predicate<ChangeData>> predicates = new ArrayList<>();