Replace com.google.common.base.Predicate with java.util.function.Predicate

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179579304
This commit is contained in:
guyben 2017-12-19 11:17:06 -08:00 committed by Ben McIlwain
parent 0bb2e12a8a
commit f1ae66d148
10 changed files with 29 additions and 32 deletions

View file

@ -15,7 +15,6 @@
package google.registry.model.domain;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Predicates.not;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
@ -30,7 +29,6 @@ import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Ordering;
@ -47,6 +45,7 @@ import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.host.HostResource;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
/** Shared base class for {@link DomainResource} and {@link DomainApplication}. */
@ -154,7 +153,10 @@ public abstract class DomainBase extends EppResource {
/** Associated contacts for the domain (other than registrant). */
public ImmutableSet<DesignatedContact> getContacts() {
return nullToEmpty(allContacts).stream().filter(not(IS_REGISTRANT)).collect(toImmutableSet());
return nullToEmpty(allContacts)
.stream()
.filter(IS_REGISTRANT.negate())
.collect(toImmutableSet());
}
public DomainAuthInfo getAuthInfo() {

View file

@ -21,8 +21,6 @@ import static com.google.common.collect.Maps.toMap;
import static google.registry.model.ofy.CommitLogBucket.getArbitraryBucketId;
import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
@ -32,8 +30,6 @@ import org.joda.time.DateTime;
/** Metadata for an {@link Ofy} transaction that saves commit logs. */
class TransactionInfo {
private static final Predicate<Object> IS_DELETE = Predicates.equalTo(Delete.SENTINEL);
private enum Delete { SENTINEL }
/** Logical "now" of the transaction. */
@ -75,7 +71,7 @@ class TransactionInfo {
void putDeletes(Iterable<Key<?>> keys) {
assertNotReadOnly();
changesBuilder.putAll(toMap(keys, k -> TransactionInfo.Delete.SENTINEL));
changesBuilder.putAll(toMap(keys, k -> Delete.SENTINEL));
}
ImmutableSet<Key<?>> getTouchedKeys() {
@ -83,7 +79,8 @@ class TransactionInfo {
}
ImmutableSet<Key<?>> getDeletes() {
return ImmutableSet.copyOf(filterValues(changesBuilder.build(), IS_DELETE).keySet());
return ImmutableSet.copyOf(
filterValues(changesBuilder.build(), Delete.SENTINEL::equals).keySet());
}
ImmutableSet<Object> getSaves() {
@ -91,7 +88,7 @@ class TransactionInfo {
.build()
.values()
.stream()
.filter(Predicates.not(IS_DELETE))
.filter(change -> !Delete.SENTINEL.equals(change))
.collect(toImmutableSet());
}
}

View file

@ -30,7 +30,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.joda.money.CurrencyUnit.USD;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@ -67,6 +66,7 @@ import java.util.Collection;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.joda.money.CurrencyUnit;