Migrate Guava Predicates.notNull to Objects.nonNull

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179569444
This commit is contained in:
mcilwain 2017-12-19 10:10:20 -08:00 committed by Ben McIlwain
parent 633eb3179a
commit 0bb2e12a8a
7 changed files with 15 additions and 16 deletions

View file

@ -16,7 +16,6 @@ package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.Maps.filterValues;
import static com.google.common.io.Resources.getResource;
@ -45,6 +44,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** A command to execute an epp command. */
abstract class EppToolCommand extends ConfirmingCommand implements ServerSideCommand {
@ -145,7 +145,7 @@ abstract class EppToolCommand extends ConfirmingCommand implements ServerSideCom
params.put("superuser", superuser);
params.put("xml", URLEncoder.encode(command.xml, UTF_8.toString()));
String requestBody =
Joiner.on('&').withKeyValueSeparator("=").join(filterValues(params, notNull()));
Joiner.on('&').withKeyValueSeparator("=").join(filterValues(params, Objects::nonNull));
responses.add(nullToEmpty(connection.send(
"/_dr/epptool",
ImmutableMap.<String, String>of(),

View file

@ -14,7 +14,6 @@
package google.registry.tools;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.util.concurrent.Futures.addCallback;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
@ -30,6 +29,7 @@ import google.registry.export.ExportConstants;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** Command to load Datastore snapshots into Bigquery. */
@Parameters(separators = " =", commandDescription = "Load Datastore snapshot into Bigquery")
@ -120,7 +120,7 @@ final class LoadSnapshotCommand extends BigqueryCommand {
}
// Block on the completion of all the load jobs.
List<?> results = Futures.successfulAsList(loadJobs.values()).get();
int numSucceeded = (int) results.stream().filter(notNull()).count();
int numSucceeded = (int) results.stream().filter(Objects::nonNull).count();
System.err.printf(
"All load jobs have terminated: %d/%d successful.\n",
numSucceeded, loadJobs.size());

View file

@ -15,7 +15,6 @@
package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static google.registry.model.registrar.Registrar.loadByClientId;
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
@ -35,6 +34,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
/** Command to verify that a registrar has passed OT&amp;E. */
@Parameters(
@ -118,7 +118,7 @@ final class VerifyOteCommand implements ServerSideCommand {
// If it matches, provide the shortened name, and otherwise return null.
return name.equals(replacedName) ? null : replacedName;
})
.filter(notNull())
.filter(Objects::nonNull)
.collect(toImmutableSet());
}
}

View file

@ -15,7 +15,6 @@
package google.registry.tools.server;
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Iterators.filter;
import static com.google.common.io.BaseEncoding.base16;
@ -58,6 +57,7 @@ import java.net.InetAddress;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;
import org.joda.time.DateTime;
import org.joda.time.Duration;
@ -255,7 +255,8 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
Writer osWriter = new OutputStreamWriter(gcsOutput, UTF_8);
PrintWriter writer = new PrintWriter(osWriter)) {
writer.printf(HEADER_FORMAT, tld);
for (Iterator<String> stanzaIter = filter(stanzas, notNull()); stanzaIter.hasNext(); ) {
for (Iterator<String> stanzaIter = filter(stanzas, Objects::nonNull);
stanzaIter.hasNext(); ) {
writer.println(stanzaIter.next());
getContext().incrementCounter(stanzaCounter);
}