Use Predicates.not for one-liner functionals when appropriate

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=193386976
This commit is contained in:
guyben 2018-04-18 11:18:05 -07:00 committed by jianglai
parent 744727a58f
commit 9ed4d43f41
3 changed files with 5 additions and 4 deletions

View file

@ -131,7 +131,7 @@ public final class TldFanoutAction implements Runnable {
runInEmpty ? Stream.of("") : Stream.of(), runInEmpty ? Stream.of("") : Stream.of(),
forEachRealTld ? getTldsOfType(REAL).stream() : Stream.of(), forEachRealTld ? getTldsOfType(REAL).stream() : Stream.of(),
forEachTestTld ? getTldsOfType(TEST).stream() : Stream.of()) forEachTestTld ? getTldsOfType(TEST).stream() : Stream.of())
.filter(tld -> !excludes.contains(tld)) .filter(not(in(excludes)))
.collect(toImmutableSet()); .collect(toImmutableSet());
Multimap<String, String> flowThruParams = filterKeys(params, not(in(CONTROL_PARAMS))); Multimap<String, String> flowThruParams = filterKeys(params, not(in(CONTROL_PARAMS)));
Queue taskQueue = getQueue(queue); Queue taskQueue = getQueue(queue);

View file

@ -15,6 +15,7 @@
package google.registry.model.ofy; package google.registry.model.ofy;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.Maps.filterValues; import static com.google.common.collect.Maps.filterValues;
import static com.google.common.collect.Maps.toMap; import static com.google.common.collect.Maps.toMap;
@ -88,7 +89,7 @@ class TransactionInfo {
.build() .build()
.values() .values()
.stream() .stream()
.filter(change -> !Delete.SENTINEL.equals(change)) .filter(not(Delete.SENTINEL::equals))
.collect(toImmutableSet()); .collect(toImmutableSet());
} }
} }

View file

@ -14,6 +14,7 @@
package google.registry.rdap; package google.registry.rdap;
import static com.google.common.base.Predicates.not;
import static com.google.common.base.Strings.nullToEmpty; import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet; import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
@ -57,7 +58,6 @@ import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -1153,7 +1153,7 @@ public class RdapJsonFormatter {
if (isDeleted) { if (isDeleted) {
stream = stream =
Streams.concat( Streams.concat(
stream.filter(rdapStatus -> !Objects.equals(rdapStatus, RdapStatus.ACTIVE)), stream.filter(not(RdapStatus.ACTIVE::equals)),
Stream.of(RdapStatus.INACTIVE)); Stream.of(RdapStatus.INACTIVE));
} }
return stream return stream