Always use the constructor to make Immutable Collection Builders

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135359669
This commit is contained in:
mcilwain 2016-10-06 08:09:47 -07:00 committed by Ben McIlwain
parent 79387f5d1e
commit b65b855067
16 changed files with 29 additions and 32 deletions

View file

@ -66,7 +66,7 @@ import org.joda.time.DateTime;
* <p>The cursor used throughout this mapreduce (overridden if necessary using the parameter
* {@code cursorTime}) represents the inclusive lower bound on the range of billing times that will
* be expanded as a result of the job (the exclusive upper bound being the execution time of the
* job).
* job).
*/
@Action(path = "/_dr/task/expandRecurringBillingEvents")
public class ExpandRecurringBillingEventsAction implements Runnable {
@ -101,7 +101,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
.runMapreduce(
new ExpandRecurringBillingEventsMapper(isDryRun, cursorTime, clock.nowUtc()),
new ExpandRecurringBillingEventsReducer(isDryRun, persistedCursorTime),
// Add an extra shard that maps over a null recurring event (see the mapper for why).
// Add an extra shard that maps over a null recurring event (see the mapper for why).
ImmutableList.of(
new NullInput<Recurring>(),
createChildEntityInput(
@ -142,7 +142,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
@Override
public Integer run() {
ImmutableSet.Builder<OneTime> syntheticOneTimesBuilder =
ImmutableSet.<OneTime>builder();
new ImmutableSet.Builder<>();
final Registry tld = Registry.get(getTldFromDomainName(recurring.getTargetId()));
// Determine the complete set of times at which this recurring event should occur
@ -224,7 +224,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
.filter(Range.closedOpen(cursorTime, executeTime))
.toSet();
}
/**
* Determines an {@link ImmutableSet} of {@link DateTime}s that have already been persisted
* for a given recurring billing event.
@ -252,7 +252,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
/**
* "Reducer" to advance the cursor after all map jobs have been completed. The NullInput into the
* mapper will cause the mapper to emit one timestamp pair (current cursor and execution time),
* and the cursor will be advanced (and the timestamps logged) at the end of a successful
* and the cursor will be advanced (and the timestamps logged) at the end of a successful
* mapreduce.
*/
public static class ExpandRecurringBillingEventsReducer
@ -294,7 +294,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
}
if (!isDryRun) {
ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, executionTime));
}
}
}
});
}

View file

@ -88,7 +88,7 @@ public class DomainAllocateFlow extends DomainCreateOrAllocateFlow {
protected final void setDomainCreateOrAllocateProperties(Builder builder) {
boolean sunrushAddGracePeriod = isNullOrEmpty(command.getNameservers());
Registry registry = Registry.get(getTld());
ImmutableSet.Builder<Flag> billingFlagsBuilder = ImmutableSet.builder();
ImmutableSet.Builder<Flag> billingFlagsBuilder = new ImmutableSet.Builder<>();
if (!application.getEncodedSignedMarks().isEmpty()) {
billingFlagsBuilder.add(Flag.SUNRISE);
} else {

View file

@ -71,7 +71,7 @@ class ChildEntityReader<R extends EppResource, I extends ImmutableObject> extend
@SuppressWarnings("unchecked")
private ImmutableList<Class<? extends I>> expandPolymorphicClasses(
ImmutableSet<Class<? extends I>> resourceClasses) {
ImmutableList.Builder<Class<? extends I>> builder = ImmutableList.builder();
ImmutableList.Builder<Class<? extends I>> builder = new ImmutableList.Builder<>();
for (Class<? extends I> clazz : resourceClasses) {
if (clazz.isAnnotationPresent(Entity.class)) {
builder.add(clazz);

View file

@ -79,7 +79,7 @@ public final class VirtualMetric<V> extends AbstractMetric<V> {
ImmutableList<MetricPoint<V>> getTimestampedValues(Instant timestamp) {
ImmutableMap<ImmutableList<String>, V> values = valuesSupplier.get();
ImmutableList.Builder<MetricPoint<V>> metricPoints = ImmutableList.builder();
ImmutableList.Builder<MetricPoint<V>> metricPoints = new ImmutableList.Builder<>();
for (Entry<ImmutableList<String>, V> entry : values.entrySet()) {
metricPoints.add(
MetricPoint.create(this, entry.getKey(), timestamp, timestamp, entry.getValue()));

View file

@ -79,7 +79,7 @@ public abstract class EppMetric implements BigQueryMetric {
public ImmutableMap<String, String> getBigQueryRowEncoding() {
// Create map builder, start with required values
ImmutableMap.Builder<String, String> map =
ImmutableMap.<String, String>builder()
new ImmutableMap.Builder<String, String>()
.put("requestId", getRequestId())
.put("startTime", toBigqueryTimestamp(getStartTimestamp()))
.put("endTime", toBigqueryTimestamp(getEndTimestamp()))

View file

@ -88,7 +88,7 @@ public final class LordnLog implements Iterable<Entry<String, LordnLog.Result>>
}
}
private static final Map<Integer, Result> RESULTS = ImmutableMap.<Integer, Result>builder()
private static final Map<Integer, Result> RESULTS = new ImmutableMap.Builder<Integer, Result>()
.put(2000, new Result(2000, "OK"))
.put(2001, new Result(2001, "OK but not processed"))
.put(3601, new Result(3601, "TCN Acceptance Date after Registration Date"))

View file

@ -81,7 +81,7 @@ abstract class EppToolCommand extends ConfirmingCommand implements ServerSideCom
* EPP calls when invoking commands (i.e. domain check) with sets of domains across multiple TLDs.
*/
protected static Multimap<String, String> validateAndGroupDomainNamesByTld(List<String> names) {
ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
ImmutableMultimap.Builder<String, String> builder = new ImmutableMultimap.Builder<>();
for (String name : names) {
InternetDomainName tld = findTldForNameOrThrow(InternetDomainName.from(name));
builder.put(tld.toString(), name);

View file

@ -45,13 +45,13 @@ public final class GetLrpTokenCommand implements RemoteApiCommand {
names = {"-h", "--history"},
description = "Return expanded history entry (including domain application)")
private boolean includeHistory = false;
@Override
public void run() throws Exception {
checkArgument(
(tokenString == null) == (assignee != null),
"Exactly one of either token or assignee must be specified.");
ImmutableSet.Builder<LrpToken> tokensBuilder = ImmutableSet.builder();
ImmutableSet.Builder<LrpToken> tokensBuilder = new ImmutableSet.Builder<>();
if (tokenString != null) {
LrpToken token = ofy().load().key(Key.create(LrpToken.class, tokenString)).now();
if (token != null) {
@ -69,7 +69,7 @@ public final class GetLrpTokenCommand implements RemoteApiCommand {
System.out.println(
ofy().load().key(token.getRedemptionHistoryEntry()).now().toHydratedString());
}
}
}
} else {
System.out.println("Token not found.");
}

View file

@ -74,7 +74,7 @@ abstract class ListObjectsCommand implements RemoteApiCommand, ServerSideCommand
@Override
public void run() throws Exception {
ImmutableMap.Builder<String, Object> params = ImmutableMap.<String, Object>builder();
ImmutableMap.Builder<String, Object> params = new ImmutableMap.Builder<>();
if (fields != null) {
params.put(FIELDS_PARAM, fields);
}

View file

@ -177,7 +177,7 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
*/
private ImmutableTable<T, String, String>
extractData(ImmutableSet<String> fields, ImmutableSet<T> objects) {
ImmutableTable.Builder<T, String, String> builder = ImmutableTable.builder();
ImmutableTable.Builder<T, String, String> builder = new ImmutableTable.Builder<>();
for (T object : objects) {
Map<String, Object> fieldMap = new HashMap<>();
// Base case of the mapping is to use ImmutableObject's toDiffableFieldMap().