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:
mcilwain 2017-02-07 10:06:28 -08:00 committed by Ben McIlwain
parent f212a53232
commit ec55aa5361
12 changed files with 18 additions and 41 deletions

View file

@ -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())

View file

@ -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);
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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;
}
}
}