Replace custom eq methods with Objects.equals
Change-Id: Ia167b23754de6f33d4d6a105accbc14e444cc98a Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/** Helper to edit a section of the configuration files. */
|
||||
@@ -100,7 +101,7 @@ public class Section {
|
||||
if (nullIfDefault && nv.equals(dv)) {
|
||||
nv = null;
|
||||
}
|
||||
if (!eq(ov, nv)) {
|
||||
if (!Objects.equals(ov, nv)) {
|
||||
set(name, nv);
|
||||
}
|
||||
return nv;
|
||||
@@ -148,7 +149,7 @@ public class Section {
|
||||
public String select(final String title, String name, String dv, Set<String> allowedValues) {
|
||||
final String ov = get(name);
|
||||
String nv = ui.readString(ov != null ? ov : dv, allowedValues, "%s", title);
|
||||
if (!eq(ov, nv)) {
|
||||
if (!Objects.equals(ov, nv)) {
|
||||
set(name, nv);
|
||||
}
|
||||
return nv;
|
||||
@@ -177,7 +178,7 @@ public class Section {
|
||||
}
|
||||
|
||||
final String nv = ui.password("%s's password", user);
|
||||
if (!eq(ov, nv)) {
|
||||
if (!Objects.equals(ov, nv)) {
|
||||
setSecure(password, nv);
|
||||
}
|
||||
return nv;
|
||||
@@ -195,7 +196,7 @@ public class Section {
|
||||
}
|
||||
|
||||
final String nv = ui.password("%s", prompt);
|
||||
if (!eq(ov, nv)) {
|
||||
if (!Objects.equals(ov, nv)) {
|
||||
setSecure(passwordKey, nv);
|
||||
}
|
||||
return nv;
|
||||
@@ -216,11 +217,4 @@ public class Section {
|
||||
String getName() {
|
||||
return section;
|
||||
}
|
||||
|
||||
private static boolean eq(String a, String b) {
|
||||
if (a == null && b == null) {
|
||||
return true;
|
||||
}
|
||||
return a != null && a.equals(b);
|
||||
}
|
||||
}
|
||||
|
@@ -49,6 +49,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
@@ -225,13 +226,13 @@ public class AccountManager {
|
||||
|
||||
if (!realm.allowsEdit(AccountFieldName.FULL_NAME)
|
||||
&& !Strings.isNullOrEmpty(who.getDisplayName())
|
||||
&& !eq(user.getAccount().getFullName(), who.getDisplayName())) {
|
||||
&& !Objects.equals(user.getAccount().getFullName(), who.getDisplayName())) {
|
||||
accountUpdates.add(u -> u.setFullName(who.getDisplayName()));
|
||||
}
|
||||
|
||||
if (!realm.allowsEdit(AccountFieldName.USER_NAME)
|
||||
&& who.getUserName() != null
|
||||
&& !eq(user.getUserName(), who.getUserName())) {
|
||||
&& !Objects.equals(user.getUserName(), who.getUserName())) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Not changing already set username %s to %s", user.getUserName(), who.getUserName()));
|
||||
@@ -249,10 +250,6 @@ public class AccountManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean eq(String a, String b) {
|
||||
return (a == null && b == null) || (a != null && a.equals(b));
|
||||
}
|
||||
|
||||
private AuthResult create(ReviewDb db, AuthRequest who)
|
||||
throws OrmException, AccountException, IOException, ConfigInvalidException {
|
||||
Account.Id newId = new Account.Id(sequences.nextAccountId());
|
||||
|
@@ -175,6 +175,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -2445,7 +2446,8 @@ class ReceiveCommits {
|
||||
// or no parents were updated (rebase), else warn that only part
|
||||
// of the commit was modified.
|
||||
if (newCommit.getTree().equals(priorCommit.getTree())) {
|
||||
boolean messageEq = eq(newCommit.getFullMessage(), priorCommit.getFullMessage());
|
||||
boolean messageEq =
|
||||
Objects.equals(newCommit.getFullMessage(), priorCommit.getFullMessage());
|
||||
boolean parentsEq = parentsEqual(newCommit, priorCommit);
|
||||
boolean authorEq = authorEqual(newCommit, priorCommit);
|
||||
ObjectReader reader = rp.getRevWalk().getObjectReader();
|
||||
@@ -2723,18 +2725,8 @@ class ReceiveCommits {
|
||||
return false;
|
||||
}
|
||||
|
||||
return eq(aAuthor.getName(), bAuthor.getName())
|
||||
&& eq(aAuthor.getEmailAddress(), bAuthor.getEmailAddress());
|
||||
}
|
||||
|
||||
static boolean eq(String a, String b) {
|
||||
if (a == null && b == null) {
|
||||
return true;
|
||||
} else if (a == null || b == null) {
|
||||
return false;
|
||||
} else {
|
||||
return a.equals(b);
|
||||
}
|
||||
return Objects.equals(aAuthor.getName(), bAuthor.getName())
|
||||
&& Objects.equals(aAuthor.getEmailAddress(), bAuthor.getEmailAddress());
|
||||
}
|
||||
|
||||
private boolean validRefOperation(ReceiveCommand cmd) {
|
||||
|
Reference in New Issue
Block a user