mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Resolve some Guava 20 TODOs (mostly unnecessary asList() calls)
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146799536
This commit is contained in:
parent
f212a53232
commit
ec55aa5361
12 changed files with 18 additions and 41 deletions
|
@ -21,7 +21,6 @@ import static com.google.common.collect.Iterables.all;
|
|||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
import static com.google.common.collect.Sets.newLinkedHashSet;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
|
@ -93,7 +92,7 @@ public class ModelUtils {
|
|||
Iterable<?> body;
|
||||
if (clazz.isEnum()) {
|
||||
stringBuilder.append("enum ");
|
||||
body = FluentIterable.from(asList(clazz.getEnumConstants()));
|
||||
body = FluentIterable.from(clazz.getEnumConstants());
|
||||
} else {
|
||||
stringBuilder.append("class ");
|
||||
body = FluentIterable.from(getAllFields(clazz).values())
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.model.ofy;
|
|||
|
||||
import static com.googlecode.objectify.ObjectifyService.ofy;
|
||||
import static google.registry.util.ObjectifyUtils.OBJECTS_TO_KEYS;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
@ -45,7 +44,7 @@ abstract class AugmentedDeleter implements Deleter {
|
|||
|
||||
@Override
|
||||
public Result<Void> entities(Object... entities) {
|
||||
handleDeletion(FluentIterable.from(asList(entities)).transform(OBJECTS_TO_KEYS));
|
||||
handleDeletion(FluentIterable.from(entities).transform(OBJECTS_TO_KEYS));
|
||||
return delegate.entities(entities);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package google.registry.model.ofy;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
@ -50,7 +48,7 @@ class TimestampInversionException extends RuntimeException {
|
|||
"Timestamp inversion between transaction time (%s) and %s",
|
||||
transactionTime,
|
||||
problem),
|
||||
getFileAndLine(FluentIterable.from(asList(new Exception().getStackTrace()))
|
||||
getFileAndLine(FluentIterable.from(new Exception().getStackTrace())
|
||||
.firstMatch(new Predicate<StackTraceElement>() {
|
||||
@Override
|
||||
public boolean apply(StackTraceElement element) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.model.registry.Registries.assertTldExists;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
|
@ -108,7 +107,7 @@ final class CreateAuctionCreditsCommand extends MutatingCommand {
|
|||
CURRENCY_CODE;
|
||||
|
||||
public static List<String> getHeaders() {
|
||||
return FluentIterable.from(asList(values()))
|
||||
return FluentIterable.from(values())
|
||||
.transform(new Function<CsvHeader, String>() {
|
||||
@Override
|
||||
public String apply(CsvHeader header) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import static google.registry.flows.picker.FlowPicker.getFlowClass;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||
import static google.registry.util.DomainNameUtils.ACE_PREFIX;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Function;
|
||||
|
@ -229,7 +228,7 @@ public class VerifyOteAction implements Runnable, JsonAction {
|
|||
UNCLASSIFIED_FLOWS(0, Predicates.<EppInput>alwaysFalse());
|
||||
|
||||
/** The number of StatTypes with a non-zero requirement. */
|
||||
private static final int NUM_REQUIREMENTS = FluentIterable.from(asList(values()))
|
||||
private static final int NUM_REQUIREMENTS = FluentIterable.from(values())
|
||||
.filter(new Predicate<StatType>() {
|
||||
@Override
|
||||
public boolean apply(@Nonnull StatType statType) {
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package google.registry.util;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import java.util.logging.Handler;
|
||||
|
@ -38,7 +36,7 @@ public class FormattingLogger {
|
|||
|
||||
private void log(Level level, Throwable cause, String msg) {
|
||||
StackTraceElement callerFrame = FluentIterable
|
||||
.from(asList(new Exception().getStackTrace()))
|
||||
.from(new Exception().getStackTrace())
|
||||
.firstMatch(new Predicate<StackTraceElement>() {
|
||||
@Override
|
||||
public boolean apply(StackTraceElement frame) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Throwables.throwIfUnchecked;
|
||||
import static com.google.common.collect.Iterables.any;
|
||||
import static com.google.common.math.IntMath.pow;
|
||||
import static google.registry.util.PredicateUtils.supertypeOf;
|
||||
|
@ -103,14 +104,4 @@ public class Retrier implements Serializable {
|
|||
return any(retryables, supertypeOf(e.getClass()));
|
||||
}});
|
||||
}
|
||||
|
||||
// TODO(user): Replace with Throwables.throwIfUnchecked
|
||||
private static void throwIfUnchecked(Throwable throwable) {
|
||||
if (throwable instanceof RuntimeException) {
|
||||
throw (RuntimeException) throwable;
|
||||
}
|
||||
if (throwable instanceof Error) {
|
||||
throw (Error) throwable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import static google.registry.testing.DatastoreHelper.getPollMessages;
|
|||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -33,6 +32,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
|
||||
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
|
||||
import google.registry.flows.picker.FlowPicker;
|
||||
|
@ -268,7 +268,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
}};
|
||||
// Ordering is irrelevant but duplicates should be considered independently.
|
||||
assertThat(FluentIterable.from(pollMessages).transform(idStripper))
|
||||
.containsExactlyElementsIn(FluentIterable.from(asList(expected)).transform(idStripper));
|
||||
.containsExactlyElementsIn(FluentIterable.from(expected).transform(idStripper));
|
||||
}
|
||||
|
||||
private EppOutput runFlowInternal(CommitMode commitMode, UserPrivileges userPrivileges)
|
||||
|
@ -318,10 +318,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
CommitMode commitMode, UserPrivileges userPrivileges, String xml, String... ignoredPaths)
|
||||
throws Exception {
|
||||
// Always ignore the server trid, since it's generated and meaningless to flow correctness.
|
||||
// TODO(user): Remove asList()
|
||||
String[] ignoredPathsPlusTrid = FluentIterable.from(asList(ignoredPaths))
|
||||
.append("epp.response.trID.svTRID")
|
||||
.toArray(String.class);
|
||||
String[] ignoredPathsPlusTrid = ObjectArrays.concat(ignoredPaths, "epp.response.trID.svTRID");
|
||||
EppOutput output = runFlowInternal(commitMode, userPrivileges);
|
||||
if (output.isResponse()) {
|
||||
assertThat(output.isSuccess()).isTrue();
|
||||
|
|
|
@ -29,7 +29,6 @@ import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
|||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -177,7 +176,7 @@ public class DomainTransferApproveFlowTest
|
|||
.build();
|
||||
assertBillingEventsForResource(
|
||||
domain,
|
||||
FluentIterable.from(asList(expectedCancellationBillingEvents))
|
||||
FluentIterable.from(expectedCancellationBillingEvents)
|
||||
.transform(new Function<BillingEvent.Cancellation.Builder, BillingEvent>() {
|
||||
@Override
|
||||
public Cancellation apply(Builder builder) {
|
||||
|
|
|
@ -28,7 +28,6 @@ import static google.registry.testing.GenericEppResourceSubject.assertAboutEppRe
|
|||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.joda.money.CurrencyUnit.EUR;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
|
@ -212,7 +211,7 @@ public class DomainTransferRequestFlowTest
|
|||
.setPeriodYears(registrationYears)
|
||||
.setParent(historyEntryTransferRequest)
|
||||
.build();
|
||||
assertBillingEvents(FluentIterable.from(asList(extraExpectedBillingEvents))
|
||||
assertBillingEvents(FluentIterable.from(extraExpectedBillingEvents)
|
||||
.transform(new Function<BillingEvent.Cancellation.Builder, BillingEvent>() {
|
||||
@Override
|
||||
public BillingEvent apply(Builder builder) {
|
||||
|
|
|
@ -35,7 +35,6 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|||
import static google.registry.util.DomainNameUtils.ACE_PREFIX_REGEX;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
|
@ -626,7 +625,7 @@ public class DatastoreHelper {
|
|||
public static void assertBillingEvents(BillingEvent... expected) throws Exception {
|
||||
assertThat(FluentIterable.from(getBillingEvents()).transform(BILLING_EVENT_ID_STRIPPER))
|
||||
.containsExactlyElementsIn(
|
||||
FluentIterable.from(asList(expected)).transform(BILLING_EVENT_ID_STRIPPER));
|
||||
FluentIterable.from(expected).transform(BILLING_EVENT_ID_STRIPPER));
|
||||
}
|
||||
|
||||
/** Assert that the expected billing events set is exactly the one found in the fake datastore. */
|
||||
|
@ -643,7 +642,7 @@ public class DatastoreHelper {
|
|||
EppResource resource, BillingEvent... expected) throws Exception {
|
||||
assertThat(FluentIterable.from(getBillingEvents(resource)).transform(BILLING_EVENT_ID_STRIPPER))
|
||||
.containsExactlyElementsIn(
|
||||
FluentIterable.from(asList(expected)).transform(BILLING_EVENT_ID_STRIPPER));
|
||||
FluentIterable.from(expected).transform(BILLING_EVENT_ID_STRIPPER));
|
||||
}
|
||||
|
||||
/** Assert that there are no billing events. */
|
||||
|
@ -664,7 +663,7 @@ public class DatastoreHelper {
|
|||
throws Exception {
|
||||
assertThat(FluentIterable.from(getPollMessages(resource)).transform(POLL_MESSAGE_ID_STRIPPER))
|
||||
.containsExactlyElementsIn(
|
||||
FluentIterable.from(asList(expected)).transform(POLL_MESSAGE_ID_STRIPPER));
|
||||
FluentIterable.from(expected).transform(POLL_MESSAGE_ID_STRIPPER));
|
||||
}
|
||||
|
||||
/** Helper to effectively erase the poll message ID to facilitate comparison. */
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.collect.Iterables.toArray;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
@ -21,7 +22,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import com.beust.jcommander.JCommander;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
@ -114,7 +114,7 @@ public abstract class CommandTestCase<C extends Command> {
|
|||
|
||||
/** Writes the data to a temporary file and then returns a path to the file. */
|
||||
String writeToNamedTmpFile(String filename, Iterable<String> data) throws IOException {
|
||||
return writeToNamedTmpFile(filename, FluentIterable.from(data).toArray(String.class));
|
||||
return writeToNamedTmpFile(filename, toArray(data, String.class));
|
||||
}
|
||||
|
||||
/** Writes the data to a temporary file and then returns a path to the file. */
|
||||
|
@ -129,7 +129,7 @@ public abstract class CommandTestCase<C extends Command> {
|
|||
|
||||
/** Writes the data to a temporary file and then returns a path to the file. */
|
||||
String writeToTmpFile(Iterable<String> data) throws IOException {
|
||||
return writeToNamedTmpFile("tmp_file", FluentIterable.from(data).toArray(String.class));
|
||||
return writeToNamedTmpFile("tmp_file", toArray(data, String.class));
|
||||
}
|
||||
|
||||
/** Returns a path to a known good certificate file. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue