Prefer requireNonNull from Java API over Guava's checkNotNull
Most replacements are a trivial one-to-one replacement of the call to checkNotNull with requireNonNull, however there are some calls that make use of checkNotNull's variable argument list and formatting parameters. Replace these with String.format wrapped in a supplier. Using the Java API rather than Guava means we can get rid of the custom implementation, and Edwin's TODO, in AccessSection. Change-Id: I1d4a6b342e3544abdbba4f05ac4308d223b6768b
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
|
||||
package com.google.gerrit.server.account.externalids;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@@ -284,7 +284,7 @@ public abstract class ExternalId implements Serializable {
|
||||
}
|
||||
|
||||
public static ExternalId createEmail(Account.Id accountId, String email) {
|
||||
return createWithEmail(SCHEME_MAILTO, email, accountId, checkNotNull(email));
|
||||
return createWithEmail(SCHEME_MAILTO, email, accountId, requireNonNull(email));
|
||||
}
|
||||
|
||||
static ExternalId create(ExternalId extId, @Nullable ObjectId blobId) {
|
||||
@@ -331,7 +331,7 @@ public abstract class ExternalId implements Serializable {
|
||||
|
||||
public static ExternalId parse(String noteId, Config externalIdConfig, ObjectId blobId)
|
||||
throws ConfigInvalidException {
|
||||
checkNotNull(blobId);
|
||||
requireNonNull(blobId);
|
||||
|
||||
Set<String> externalIdKeys = externalIdConfig.getSubsections(EXTERNAL_ID_SECTION);
|
||||
if (externalIdKeys.size() != 1) {
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
package com.google.gerrit.server.account.externalids;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||
@@ -284,15 +284,15 @@ public class ExternalIdNotes extends VersionedMetaData {
|
||||
MetricMaker metricMaker,
|
||||
AllUsersName allUsersName,
|
||||
Repository allUsersRepo) {
|
||||
this.externalIdCache = checkNotNull(externalIdCache, "externalIdCache");
|
||||
this.externalIdCache = requireNonNull(externalIdCache, "externalIdCache");
|
||||
this.accountCache = accountCache;
|
||||
this.accountIndexer = accountIndexer;
|
||||
this.updateCount =
|
||||
metricMaker.newCounter(
|
||||
"notedb/external_id_update_count",
|
||||
new Description("Total number of external ID updates.").setRate().setUnit("updates"));
|
||||
this.allUsersName = checkNotNull(allUsersName, "allUsersRepo");
|
||||
this.repo = checkNotNull(allUsersRepo, "allUsersRepo");
|
||||
this.allUsersName = requireNonNull(allUsersName, "allUsersRepo");
|
||||
this.repo = requireNonNull(allUsersRepo, "allUsersRepo");
|
||||
}
|
||||
|
||||
public ExternalIdNotes setAfterReadRevision(Runnable afterReadRevision) {
|
||||
|
||||
Reference in New Issue
Block a user