mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Replace Stream.concat with Streams.concat
Stream.concat only accepts 2 parameters. Streams.concat on the other hand accepts any number of parameters. Moving to Streams.concat for all uses (2 or more) makes sense for uniformity and convenience reasons. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179716648
This commit is contained in:
parent
eb07768200
commit
2c96633a20
9 changed files with 21 additions and 16 deletions
|
@ -28,6 +28,7 @@ import com.google.appengine.tools.cloudstorage.GcsFileMetadata;
|
||||||
import com.google.appengine.tools.cloudstorage.GcsService;
|
import com.google.appengine.tools.cloudstorage.GcsService;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.PeekingIterator;
|
import com.google.common.collect.PeekingIterator;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Result;
|
import com.googlecode.objectify.Result;
|
||||||
import com.googlecode.objectify.util.ResultNow;
|
import com.googlecode.objectify.util.ResultNow;
|
||||||
|
@ -116,7 +117,7 @@ public class RestoreCommitLogsAction implements Runnable {
|
||||||
}
|
}
|
||||||
// Restore the CommitLogCheckpointRoot and CommitLogBuckets.
|
// Restore the CommitLogCheckpointRoot and CommitLogBuckets.
|
||||||
saveOfy(
|
saveOfy(
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
bucketTimestamps
|
bucketTimestamps
|
||||||
.entrySet()
|
.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
|
|
@ -20,13 +20,13 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import google.registry.model.Buildable;
|
import google.registry.model.Buildable;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.domain.fee.BaseFee;
|
import google.registry.model.domain.fee.BaseFee;
|
||||||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
import google.registry.model.domain.fee.BaseFee.FeeType;
|
||||||
import google.registry.model.domain.fee.Credit;
|
import google.registry.model.domain.fee.Credit;
|
||||||
import google.registry.model.domain.fee.Fee;
|
import google.registry.model.domain.fee.Fee;
|
||||||
import java.util.stream.Stream;
|
|
||||||
import org.joda.money.CurrencyUnit;
|
import org.joda.money.CurrencyUnit;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class FeesAndCredits extends ImmutableObject implements Buildable {
|
||||||
|
|
||||||
/** Returns all fees and credits for the event. */
|
/** Returns all fees and credits for the event. */
|
||||||
public ImmutableList<BaseFee> getFeesAndCredits() {
|
public ImmutableList<BaseFee> getFeesAndCredits() {
|
||||||
return Stream.concat(getFees().stream(), getCredits().stream()).collect(toImmutableList());
|
return Streams.concat(getFees().stream(), getCredits().stream()).collect(toImmutableList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,6 +32,7 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||||
|
@ -46,7 +47,6 @@ import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/** Shared base class for {@link DomainResource} and {@link DomainApplication}. */
|
/** Shared base class for {@link DomainResource} and {@link DomainApplication}. */
|
||||||
@ReportedOn
|
@ReportedOn
|
||||||
|
@ -250,7 +250,7 @@ public abstract class DomainBase extends EppResource {
|
||||||
checkArgument(contacts.stream().noneMatch(IS_REGISTRANT), "Registrant cannot be a contact");
|
checkArgument(contacts.stream().noneMatch(IS_REGISTRANT), "Registrant cannot be a contact");
|
||||||
// Replace the non-registrant contacts inside allContacts.
|
// Replace the non-registrant contacts inside allContacts.
|
||||||
getInstance().allContacts =
|
getInstance().allContacts =
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
nullToEmpty(getInstance().allContacts).stream().filter(IS_REGISTRANT),
|
nullToEmpty(getInstance().allContacts).stream().filter(IS_REGISTRANT),
|
||||||
contacts.stream())
|
contacts.stream())
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import com.google.appengine.api.datastore.DatastoreServiceFactory;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Objectify;
|
import com.googlecode.objectify.Objectify;
|
||||||
import com.googlecode.objectify.ObjectifyFactory;
|
import com.googlecode.objectify.ObjectifyFactory;
|
||||||
|
@ -45,7 +46,6 @@ import google.registry.model.translators.InetAddressTranslatorFactory;
|
||||||
import google.registry.model.translators.ReadableInstantUtcTranslatorFactory;
|
import google.registry.model.translators.ReadableInstantUtcTranslatorFactory;
|
||||||
import google.registry.model.translators.UpdateAutoTimestampTranslatorFactory;
|
import google.registry.model.translators.UpdateAutoTimestampTranslatorFactory;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An instance of Ofy, obtained via {@code #ofy()}, should be used to access all persistable
|
* An instance of Ofy, obtained via {@code #ofy()}, should be used to access all persistable
|
||||||
|
@ -140,7 +140,7 @@ public class ObjectifyService {
|
||||||
// This is future-proofing for Objectify 5.x where the registration logic gets less lenient.
|
// This is future-proofing for Objectify 5.x where the registration logic gets less lenient.
|
||||||
|
|
||||||
for (Class<?> clazz :
|
for (Class<?> clazz :
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
entityClasses.stream().filter(hasAnnotation(Entity.class)),
|
entityClasses.stream().filter(hasAnnotation(Entity.class)),
|
||||||
entityClasses.stream().filter(hasAnnotation(Entity.class).negate()))
|
entityClasses.stream().filter(hasAnnotation(Entity.class).negate()))
|
||||||
.collect(toImmutableSet())) {
|
.collect(toImmutableSet())) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import com.google.appengine.tools.mapreduce.Mapper;
|
||||||
import com.google.appengine.tools.mapreduce.inputs.InMemoryInput;
|
import com.google.appengine.tools.mapreduce.inputs.InMemoryInput;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.config.RegistryEnvironment;
|
import google.registry.config.RegistryEnvironment;
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
|
@ -66,7 +67,7 @@ public class KillAllCommitLogsAction implements Runnable {
|
||||||
Input<Key<?>> input =
|
Input<Key<?>> input =
|
||||||
new InMemoryInput<>(
|
new InMemoryInput<>(
|
||||||
Lists.partition(
|
Lists.partition(
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
Stream.of(CommitLogCheckpointRoot.getKey()),
|
Stream.of(CommitLogCheckpointRoot.getKey()),
|
||||||
CommitLogBucket.getAllBucketKeys().stream())
|
CommitLogBucket.getAllBucketKeys().stream())
|
||||||
.collect(toImmutableList()),
|
.collect(toImmutableList()),
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.ImmutableTable;
|
import com.google.common.collect.ImmutableTable;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.request.JsonResponse;
|
import google.registry.request.JsonResponse;
|
||||||
import google.registry.request.Parameter;
|
import google.registry.request.Parameter;
|
||||||
|
@ -150,7 +151,7 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
|
||||||
final ImmutableMap<String, String> nameMapping =
|
final ImmutableMap<String, String> nameMapping =
|
||||||
((fullFieldNames != null) && fullFieldNames.isPresent() && fullFieldNames.get())
|
((fullFieldNames != null) && fullFieldNames.isPresent() && fullFieldNames.get())
|
||||||
? getFieldAliases() : getFieldAliases().inverse();
|
? getFieldAliases() : getFieldAliases().inverse();
|
||||||
return Stream.concat(getPrimaryKeyFields().stream(), fieldsToUse.stream())
|
return Streams.concat(getPrimaryKeyFields().stream(), fieldsToUse.stream())
|
||||||
.map(field -> nameMapping.getOrDefault(field, field))
|
.map(field -> nameMapping.getOrDefault(field, field))
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
}
|
}
|
||||||
|
@ -207,7 +208,7 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
|
||||||
Maps.transformEntries(
|
Maps.transformEntries(
|
||||||
data.columnMap(),
|
data.columnMap(),
|
||||||
(columnName, columnValues) ->
|
(columnName, columnValues) ->
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
Stream.of(includingHeader ? columnName : ""),
|
Stream.of(includingHeader ? columnName : ""),
|
||||||
columnValues.values().stream())
|
columnValues.values().stream())
|
||||||
.map(String::length)
|
.map(String::length)
|
||||||
|
|
|
@ -41,6 +41,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||||
|
@ -262,7 +263,7 @@ public class DomainTransferApproveFlowTest
|
||||||
.build();
|
.build();
|
||||||
assertBillingEventsForResource(
|
assertBillingEventsForResource(
|
||||||
domain,
|
domain,
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
Arrays.stream(expectedCancellationBillingEvents)
|
Arrays.stream(expectedCancellationBillingEvents)
|
||||||
.map(builder -> builder.setParent(historyEntryTransferApproved).build()),
|
.map(builder -> builder.setParent(historyEntryTransferApproved).build()),
|
||||||
Stream.of(
|
Stream.of(
|
||||||
|
@ -298,7 +299,7 @@ public class DomainTransferApproveFlowTest
|
||||||
// for the gaining client that begins at the new expiration time.
|
// for the gaining client that begins at the new expiration time.
|
||||||
assertBillingEventsForResource(
|
assertBillingEventsForResource(
|
||||||
domain,
|
domain,
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
Arrays.stream(expectedCancellationBillingEvents)
|
Arrays.stream(expectedCancellationBillingEvents)
|
||||||
.map(builder -> builder.setParent(historyEntryTransferApproved).build()),
|
.map(builder -> builder.setParent(historyEntryTransferApproved).build()),
|
||||||
Stream.of(
|
Stream.of(
|
||||||
|
|
|
@ -48,6 +48,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppRequestSource;
|
import google.registry.flows.EppRequestSource;
|
||||||
|
@ -313,7 +314,7 @@ public class DomainTransferRequestFlowTest
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
// Assert that the billing events we constructed above actually exist in Datastore.
|
// Assert that the billing events we constructed above actually exist in Datastore.
|
||||||
ImmutableSet<BillingEvent> expectedBillingEvents =
|
ImmutableSet<BillingEvent> expectedBillingEvents =
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
Stream.of(losingClientAutorenew, gainingClientAutorenew),
|
Stream.of(losingClientAutorenew, gainingClientAutorenew),
|
||||||
optionalToStream(optionalTransferBillingEvent))
|
optionalToStream(optionalTransferBillingEvent))
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
|
@ -332,7 +333,7 @@ public class DomainTransferRequestFlowTest
|
||||||
// Assert that the full set of server-approve billing events is exactly the extra ones plus
|
// Assert that the full set of server-approve billing events is exactly the extra ones plus
|
||||||
// the transfer billing event (if present) and the gaining client autorenew.
|
// the transfer billing event (if present) and the gaining client autorenew.
|
||||||
ImmutableSet<BillingEvent> expectedServeApproveBillingEvents =
|
ImmutableSet<BillingEvent> expectedServeApproveBillingEvents =
|
||||||
Stream.concat(
|
Streams.concat(
|
||||||
Stream.of(gainingClientAutorenew), optionalToStream(optionalTransferBillingEvent))
|
Stream.of(gainingClientAutorenew), optionalToStream(optionalTransferBillingEvent))
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
assertBillingEventsEqual(
|
assertBillingEventsEqual(
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
|
@ -51,7 +52,6 @@ import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.model.transfer.TransferData;
|
import google.registry.model.transfer.TransferData;
|
||||||
import google.registry.model.transfer.TransferStatus;
|
import google.registry.model.transfer.TransferStatus;
|
||||||
import java.util.stream.Stream;
|
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -369,7 +369,7 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
domain
|
domain
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setGracePeriods(
|
.setGracePeriods(
|
||||||
Stream.concat(addGracePeriods.stream(), renewGracePeriods.stream())
|
Streams.concat(addGracePeriods.stream(), renewGracePeriods.stream())
|
||||||
.collect(toImmutableSet()))
|
.collect(toImmutableSet()))
|
||||||
.build();
|
.build();
|
||||||
assertThat(domain.getGracePeriodsOfType(GracePeriodStatus.ADD)).isEqualTo(addGracePeriods);
|
assertThat(domain.getGracePeriodsOfType(GracePeriodStatus.ADD)).isEqualTo(addGracePeriods);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue