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

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179249159
This commit is contained in:
guyben 2017-12-15 15:41:05 -08:00 committed by Ben McIlwain
parent d538dca2e0
commit 8157928a35
53 changed files with 424 additions and 399 deletions

View file

@ -24,7 +24,6 @@ import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables;
@ -43,6 +42,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
import org.joda.money.BigMoney;
import org.joda.money.CurrencyUnit;

View file

@ -15,9 +15,9 @@
package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
import static java.util.stream.Collectors.toList;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.Parameters;
@ -64,7 +64,8 @@ public class LockDomainCommand extends LockOrUnlockDomainCommand {
"addNameservers", ImmutableList.of(),
"addAdmins", ImmutableList.of(),
"addTechs", ImmutableList.of(),
"addStatuses", statusesToAdd.stream().map(StatusValue::getXmlName).collect(toList()),
"addStatuses",
statusesToAdd.stream().map(StatusValue::getXmlName).collect(toImmutableList()),
"remove", false,
"removeNameservers", ImmutableList.of(),
"removeAdmins", ImmutableList.of(),

View file

@ -16,7 +16,6 @@ package google.registry.tools;
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
import static com.google.common.base.Functions.toStringFunction;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
@ -227,6 +226,6 @@ public abstract class MutatingCommand extends ConfirmingCommand implements Remot
protected String prompt() {
return changedEntitiesMap.isEmpty()
? "No entity changes to apply."
: changedEntitiesMap.values().stream().map(toStringFunction()).collect(joining("\n"));
: changedEntitiesMap.values().stream().map(Object::toString).collect(joining("\n"));
}
}

View file

@ -17,7 +17,6 @@ package google.registry.tools;
import static java.util.stream.Collectors.joining;
import com.beust.jcommander.Parameters;
import com.google.common.base.Functions;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
import google.registry.rde.PendingDeposit;
@ -49,7 +48,7 @@ final class PendingEscrowCommand implements RemoteApiCommand {
SORTER
.sortedCopy(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda().values())
.stream()
.map(Functions.toStringFunction())
.map(Object::toString)
.collect(joining("\n")));
}
}

View file

@ -15,9 +15,9 @@
package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
import static java.util.stream.Collectors.toList;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.Parameters;
@ -71,7 +71,7 @@ public class UnlockDomainCommand extends LockOrUnlockDomainCommand {
"removeAdmins", ImmutableList.of(),
"removeTechs", ImmutableList.of(),
"removeStatuses",
statusesToRemove.stream().map(StatusValue::getXmlName).collect(toList()),
statusesToRemove.stream().map(StatusValue::getXmlName).collect(toImmutableList()),
"change", false));
}
}

View file

@ -18,8 +18,6 @@ import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
@ -42,6 +40,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Stream;
import javax.inject.Inject;
@ -187,7 +186,7 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
// Next, add to the mapping all the aliases, with their values defined as whatever was in the
// map under the aliased field's original name.
fieldMap.putAll(
Maps.transformValues(getFieldAliases(), Functions.forMap(new HashMap<>(fieldMap))));
new HashMap<>(Maps.transformValues(getFieldAliases(), value -> fieldMap.get(value))));
Set<String> expectedFields = ImmutableSortedSet.copyOf(fieldMap.keySet());
for (String field : fields) {
checkArgument(fieldMap.containsKey(field),
@ -235,8 +234,7 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
if (isHeaderRowInUse(data)) {
// Add a row of headers (column names mapping to themselves).
Map<String, String> headerRow =
Maps.asMap(data.columnKeySet(), Functions.identity());
Map<String, String> headerRow = Maps.asMap(data.columnKeySet(), key -> key);
lines.add(rowFormatter.apply(headerRow));
// Add a row of separator lines (column names mapping to '-' * column width).