mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
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:
parent
79387f5d1e
commit
b65b855067
16 changed files with 29 additions and 32 deletions
|
@ -142,7 +142,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public Integer run() {
|
public Integer run() {
|
||||||
ImmutableSet.Builder<OneTime> syntheticOneTimesBuilder =
|
ImmutableSet.Builder<OneTime> syntheticOneTimesBuilder =
|
||||||
ImmutableSet.<OneTime>builder();
|
new ImmutableSet.Builder<>();
|
||||||
final Registry tld = Registry.get(getTldFromDomainName(recurring.getTargetId()));
|
final Registry tld = Registry.get(getTldFromDomainName(recurring.getTargetId()));
|
||||||
|
|
||||||
// Determine the complete set of times at which this recurring event should occur
|
// Determine the complete set of times at which this recurring event should occur
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class DomainAllocateFlow extends DomainCreateOrAllocateFlow {
|
||||||
protected final void setDomainCreateOrAllocateProperties(Builder builder) {
|
protected final void setDomainCreateOrAllocateProperties(Builder builder) {
|
||||||
boolean sunrushAddGracePeriod = isNullOrEmpty(command.getNameservers());
|
boolean sunrushAddGracePeriod = isNullOrEmpty(command.getNameservers());
|
||||||
Registry registry = Registry.get(getTld());
|
Registry registry = Registry.get(getTld());
|
||||||
ImmutableSet.Builder<Flag> billingFlagsBuilder = ImmutableSet.builder();
|
ImmutableSet.Builder<Flag> billingFlagsBuilder = new ImmutableSet.Builder<>();
|
||||||
if (!application.getEncodedSignedMarks().isEmpty()) {
|
if (!application.getEncodedSignedMarks().isEmpty()) {
|
||||||
billingFlagsBuilder.add(Flag.SUNRISE);
|
billingFlagsBuilder.add(Flag.SUNRISE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -71,7 +71,7 @@ class ChildEntityReader<R extends EppResource, I extends ImmutableObject> extend
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private ImmutableList<Class<? extends I>> expandPolymorphicClasses(
|
private ImmutableList<Class<? extends I>> expandPolymorphicClasses(
|
||||||
ImmutableSet<Class<? extends I>> resourceClasses) {
|
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) {
|
for (Class<? extends I> clazz : resourceClasses) {
|
||||||
if (clazz.isAnnotationPresent(Entity.class)) {
|
if (clazz.isAnnotationPresent(Entity.class)) {
|
||||||
builder.add(clazz);
|
builder.add(clazz);
|
||||||
|
|
|
@ -79,7 +79,7 @@ public final class VirtualMetric<V> extends AbstractMetric<V> {
|
||||||
ImmutableList<MetricPoint<V>> getTimestampedValues(Instant timestamp) {
|
ImmutableList<MetricPoint<V>> getTimestampedValues(Instant timestamp) {
|
||||||
ImmutableMap<ImmutableList<String>, V> values = valuesSupplier.get();
|
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()) {
|
for (Entry<ImmutableList<String>, V> entry : values.entrySet()) {
|
||||||
metricPoints.add(
|
metricPoints.add(
|
||||||
MetricPoint.create(this, entry.getKey(), timestamp, timestamp, entry.getValue()));
|
MetricPoint.create(this, entry.getKey(), timestamp, timestamp, entry.getValue()));
|
||||||
|
|
|
@ -79,7 +79,7 @@ public abstract class EppMetric implements BigQueryMetric {
|
||||||
public ImmutableMap<String, String> getBigQueryRowEncoding() {
|
public ImmutableMap<String, String> getBigQueryRowEncoding() {
|
||||||
// Create map builder, start with required values
|
// Create map builder, start with required values
|
||||||
ImmutableMap.Builder<String, String> map =
|
ImmutableMap.Builder<String, String> map =
|
||||||
ImmutableMap.<String, String>builder()
|
new ImmutableMap.Builder<String, String>()
|
||||||
.put("requestId", getRequestId())
|
.put("requestId", getRequestId())
|
||||||
.put("startTime", toBigqueryTimestamp(getStartTimestamp()))
|
.put("startTime", toBigqueryTimestamp(getStartTimestamp()))
|
||||||
.put("endTime", toBigqueryTimestamp(getEndTimestamp()))
|
.put("endTime", toBigqueryTimestamp(getEndTimestamp()))
|
||||||
|
|
|
@ -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(2000, new Result(2000, "OK"))
|
||||||
.put(2001, new Result(2001, "OK but not processed"))
|
.put(2001, new Result(2001, "OK but not processed"))
|
||||||
.put(3601, new Result(3601, "TCN Acceptance Date after Registration Date"))
|
.put(3601, new Result(3601, "TCN Acceptance Date after Registration Date"))
|
||||||
|
|
|
@ -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.
|
* 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) {
|
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) {
|
for (String name : names) {
|
||||||
InternetDomainName tld = findTldForNameOrThrow(InternetDomainName.from(name));
|
InternetDomainName tld = findTldForNameOrThrow(InternetDomainName.from(name));
|
||||||
builder.put(tld.toString(), name);
|
builder.put(tld.toString(), name);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public final class GetLrpTokenCommand implements RemoteApiCommand {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
(tokenString == null) == (assignee != null),
|
(tokenString == null) == (assignee != null),
|
||||||
"Exactly one of either token or assignee must be specified.");
|
"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) {
|
if (tokenString != null) {
|
||||||
LrpToken token = ofy().load().key(Key.create(LrpToken.class, tokenString)).now();
|
LrpToken token = ofy().load().key(Key.create(LrpToken.class, tokenString)).now();
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ abstract class ListObjectsCommand implements RemoteApiCommand, ServerSideCommand
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() throws Exception {
|
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) {
|
if (fields != null) {
|
||||||
params.put(FIELDS_PARAM, fields);
|
params.put(FIELDS_PARAM, fields);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
|
||||||
*/
|
*/
|
||||||
private ImmutableTable<T, String, String>
|
private ImmutableTable<T, String, String>
|
||||||
extractData(ImmutableSet<String> fields, ImmutableSet<T> objects) {
|
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) {
|
for (T object : objects) {
|
||||||
Map<String, Object> fieldMap = new HashMap<>();
|
Map<String, Object> fieldMap = new HashMap<>();
|
||||||
// Base case of the mapping is to use ImmutableObject's toDiffableFieldMap().
|
// Base case of the mapping is to use ImmutableObject's toDiffableFieldMap().
|
||||||
|
|
|
@ -213,8 +213,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
.setParent(historyEntry)
|
.setParent(historyEntry)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ImmutableSet<BillingEvent> billingEvents = ImmutableSet.of(
|
ImmutableSet.Builder<BillingEvent> expectedBillingEvents =
|
||||||
createBillingEvent, renewBillingEvent);
|
new ImmutableSet.Builder<BillingEvent>().add(createBillingEvent).add(renewBillingEvent);
|
||||||
|
|
||||||
// If EAP is applied, a billing event for EAP should be present.
|
// If EAP is applied, a billing event for EAP should be present.
|
||||||
if (!eapFee.isZero()) {
|
if (!eapFee.isZero()) {
|
||||||
|
@ -229,12 +229,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
.setFlags(billingFlags)
|
.setFlags(billingFlags)
|
||||||
.setParent(historyEntry)
|
.setParent(historyEntry)
|
||||||
.build();
|
.build();
|
||||||
billingEvents = ImmutableSet.<BillingEvent>builder()
|
expectedBillingEvents.add(eapBillingEvent);
|
||||||
.addAll(billingEvents)
|
|
||||||
.add(eapBillingEvent)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
assertBillingEvents(billingEvents);
|
assertBillingEvents(expectedBillingEvents.build());
|
||||||
|
|
||||||
assertGracePeriods(
|
assertGracePeriods(
|
||||||
domain.getGracePeriods(),
|
domain.getGracePeriods(),
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class EppResourceIndexTest extends EntityTestCase {
|
||||||
*/
|
*/
|
||||||
private ImmutableList<EppResourceIndex> getEppResourceIndexObjects() {
|
private ImmutableList<EppResourceIndex> getEppResourceIndexObjects() {
|
||||||
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
|
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
|
||||||
ImmutableList.Builder<EppResourceIndex> indexEntities = ImmutableList.builder();
|
ImmutableList.Builder<EppResourceIndex> indexEntities = new ImmutableList.Builder<>();
|
||||||
for (int i = 0; i < numBuckets; i++) {
|
for (int i = 0; i < numBuckets; i++) {
|
||||||
indexEntities.addAll(ofy().load()
|
indexEntities.addAll(ofy().load()
|
||||||
.type(EppResourceIndex.class)
|
.type(EppResourceIndex.class)
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class RdapActionBaseTest {
|
||||||
if (pathSearchString.equals("RuntimeException")) {
|
if (pathSearchString.equals("RuntimeException")) {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||||
builder.put("key", "value");
|
builder.put("key", "value");
|
||||||
RdapJsonFormatter.addTopLevelEntries(
|
RdapJsonFormatter.addTopLevelEntries(
|
||||||
builder,
|
builder,
|
||||||
|
|
|
@ -468,7 +468,7 @@ public class RdapJsonFormatterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTopLevel() throws Exception {
|
public void testTopLevel() throws Exception {
|
||||||
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||||
builder.put("key", "value");
|
builder.put("key", "value");
|
||||||
RdapJsonFormatter.addTopLevelEntries(
|
RdapJsonFormatter.addTopLevelEntries(
|
||||||
builder,
|
builder,
|
||||||
|
@ -481,7 +481,7 @@ public class RdapJsonFormatterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTopLevel_withTermsOfService() throws Exception {
|
public void testTopLevel_withTermsOfService() throws Exception {
|
||||||
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||||
builder.put("key", "value");
|
builder.put("key", "value");
|
||||||
RdapJsonFormatter.addTopLevelEntries(
|
RdapJsonFormatter.addTopLevelEntries(
|
||||||
builder,
|
builder,
|
||||||
|
@ -494,7 +494,7 @@ public class RdapJsonFormatterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTopLevel_domain() throws Exception {
|
public void testTopLevel_domain() throws Exception {
|
||||||
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||||
builder.put("key", "value");
|
builder.put("key", "value");
|
||||||
RdapJsonFormatter.addTopLevelEntries(
|
RdapJsonFormatter.addTopLevelEntries(
|
||||||
builder,
|
builder,
|
||||||
|
@ -507,7 +507,7 @@ public class RdapJsonFormatterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTopLevel_domainWithTermsOfService() throws Exception {
|
public void testTopLevel_domainWithTermsOfService() throws Exception {
|
||||||
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||||
builder.put("key", "value");
|
builder.put("key", "value");
|
||||||
RdapJsonFormatter.addTopLevelEntries(
|
RdapJsonFormatter.addTopLevelEntries(
|
||||||
builder,
|
builder,
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class TaskQueueHelper {
|
||||||
if (info.getTagAsBytes() != null) {
|
if (info.getTagAsBytes() != null) {
|
||||||
this.tag = new String(info.getTagAsBytes(), UTF_8);
|
this.tag = new String(info.getTagAsBytes(), UTF_8);
|
||||||
}
|
}
|
||||||
ImmutableMultimap.Builder<String, String> headerBuilder = ImmutableMultimap.builder();
|
ImmutableMultimap.Builder<String, String> headerBuilder = new ImmutableMultimap.Builder<>();
|
||||||
for (HeaderWrapper header : info.getHeaders()) {
|
for (HeaderWrapper header : info.getHeaders()) {
|
||||||
// Lowercase header name for comparison since HTTP
|
// Lowercase header name for comparison since HTTP
|
||||||
// header names are case-insensitive.
|
// header names are case-insensitive.
|
||||||
|
|
|
@ -79,7 +79,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
||||||
Optional<Boolean> printHeaderRow,
|
Optional<Boolean> printHeaderRow,
|
||||||
Optional<Boolean> fullFieldNames) throws Exception {
|
Optional<Boolean> fullFieldNames) throws Exception {
|
||||||
|
|
||||||
ImmutableMap.Builder<String, Object> params = ImmutableMap.<String, Object>builder();
|
ImmutableMap.Builder<String, Object> params = new ImmutableMap.Builder<>();
|
||||||
if (fields != null) {
|
if (fields != null) {
|
||||||
params.put(FIELDS_PARAM, fields);
|
params.put(FIELDS_PARAM, fields);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue