mirror of
https://github.com/google/nomulus.git
synced 2025-08-20 08:24:13 +02:00
Run automatic Java 8 conversion over codebase
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171174380
This commit is contained in:
parent
44df5da771
commit
5edb7935ed
190 changed files with 2312 additions and 3096 deletions
|
@ -19,6 +19,7 @@ import static com.google.common.base.Predicates.equalTo;
|
|||
import static com.google.common.base.Predicates.in;
|
||||
import static com.google.common.base.Predicates.not;
|
||||
import static com.google.common.base.Strings.emptyToNull;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Maps.filterValues;
|
||||
import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
|
@ -28,9 +29,9 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
|||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Work;
|
||||
import google.registry.model.registry.Registry.TldType;
|
||||
|
@ -50,19 +51,22 @@ public final class Registries {
|
|||
* query inside an unrelated client-affecting transaction.
|
||||
*/
|
||||
private static Supplier<ImmutableMap<String, TldType>> createFreshCache() {
|
||||
return memoizeWithShortExpiration(new Supplier<ImmutableMap<String, TldType>>() {
|
||||
@Override
|
||||
public ImmutableMap<String, TldType> get() {
|
||||
return ofy().doTransactionless(new Work<ImmutableMap<String, TldType>>() {
|
||||
@Override
|
||||
public ImmutableMap<String, TldType> run() {
|
||||
ImmutableMap.Builder<String, TldType> builder = new ImmutableMap.Builder<>();
|
||||
for (Registry registry : ofy().load().type(Registry.class).ancestor(getCrossTldKey())) {
|
||||
builder.put(registry.getTldStr(), registry.getTldType());
|
||||
}
|
||||
return builder.build();
|
||||
}});
|
||||
}});
|
||||
return memoizeWithShortExpiration(
|
||||
() ->
|
||||
ofy()
|
||||
.doTransactionless(
|
||||
new Work<ImmutableMap<String, TldType>>() {
|
||||
@Override
|
||||
public ImmutableMap<String, TldType> run() {
|
||||
ImmutableMap.Builder<String, TldType> builder =
|
||||
new ImmutableMap.Builder<>();
|
||||
for (Registry registry :
|
||||
ofy().load().type(Registry.class).ancestor(getCrossTldKey())) {
|
||||
builder.put(registry.getTldStr(), registry.getTldType());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/** Manually reset the static cache backing the methods on this class. */
|
||||
|
@ -93,7 +97,8 @@ public final class Registries {
|
|||
for (String tld : tlds) {
|
||||
checkArgumentNotNull(emptyToNull(tld), "Null or empty TLD specified");
|
||||
}
|
||||
ImmutableSet<String> badTlds = FluentIterable.from(tlds).filter(not(in(getTlds()))).toSet();
|
||||
ImmutableSet<String> badTlds =
|
||||
Streams.stream(tlds).filter(not(in(getTlds()))).collect(toImmutableSet());
|
||||
checkArgument(badTlds.isEmpty(), "TLDs do not exist: %s", Joiner.on(", ").join(badTlds));
|
||||
return tlds;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static com.google.common.base.Predicates.not;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static google.registry.config.RegistryConfig.getSingletonCacheRefreshDuration;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
@ -34,7 +35,6 @@ import com.google.common.base.Predicate;
|
|||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
@ -799,15 +799,12 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
}
|
||||
ImmutableSet<Entry<String, Collection<String>>> conflicts =
|
||||
FluentIterable.from(allAuthCodes.asMap().entrySet())
|
||||
.filter(
|
||||
new Predicate<Entry<String, Collection<String>>>() {
|
||||
@Override
|
||||
public boolean apply(Entry<String, Collection<String>> entry) {
|
||||
return entry.getValue().size() > 1;
|
||||
}
|
||||
})
|
||||
.toSet();
|
||||
allAuthCodes
|
||||
.asMap()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter((Entry<String, Collection<String>> entry) -> entry.getValue().size() > 1)
|
||||
.collect(toImmutableSet());
|
||||
checkArgument(
|
||||
conflicts.isEmpty(),
|
||||
"Cannot set reserved lists because of auth code conflicts for labels: %s",
|
||||
|
@ -837,14 +834,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
ImmutableSortedMap<DateTime, Money> renewCostsMap) {
|
||||
checkArgumentNotNull(renewCostsMap, "Renew billing costs map cannot be null");
|
||||
checkArgument(
|
||||
Iterables.all(
|
||||
renewCostsMap.values(),
|
||||
new Predicate<Money>() {
|
||||
@Override
|
||||
public boolean apply(Money amount) {
|
||||
return amount.isPositiveOrZero();
|
||||
}
|
||||
}),
|
||||
renewCostsMap.values().stream().allMatch(Money::isPositiveOrZero),
|
||||
"Renew billing cost cannot be negative");
|
||||
getInstance().renewBillingCostTransitions =
|
||||
TimedTransitionProperty.fromValueMap(renewCostsMap, BillingCostTransition.class);
|
||||
|
@ -855,14 +845,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
public Builder setEapFeeSchedule(ImmutableSortedMap<DateTime, Money> eapFeeSchedule) {
|
||||
checkArgumentNotNull(eapFeeSchedule, "EAP schedule map cannot be null");
|
||||
checkArgument(
|
||||
Iterables.all(
|
||||
eapFeeSchedule.values(),
|
||||
new Predicate<Money>() {
|
||||
@Override
|
||||
public boolean apply(Money amount) {
|
||||
return amount.isPositiveOrZero();
|
||||
}
|
||||
}),
|
||||
eapFeeSchedule.values().stream().allMatch(Money::isPositiveOrZero),
|
||||
"EAP fee cannot be negative");
|
||||
getInstance().eapFeeSchedule =
|
||||
TimedTransitionProperty.fromValueMap(eapFeeSchedule, BillingCostTransition.class);
|
||||
|
@ -939,17 +922,12 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
instance.getServerStatusChangeCost().getCurrencyUnit().equals(instance.currency),
|
||||
"Server status change cost must be in the registry's currency");
|
||||
Predicate<Money> currencyCheck =
|
||||
new Predicate<Money>() {
|
||||
@Override
|
||||
public boolean apply(Money money) {
|
||||
return money.getCurrencyUnit().equals(instance.currency);
|
||||
}
|
||||
};
|
||||
(Money money) -> money.getCurrencyUnit().equals(instance.currency);
|
||||
checkArgument(
|
||||
Iterables.all(instance.getRenewBillingCostTransitions().values(), currencyCheck),
|
||||
instance.getRenewBillingCostTransitions().values().stream().allMatch(currencyCheck),
|
||||
"Renew cost must be in the registry's currency");
|
||||
checkArgument(
|
||||
Iterables.all(instance.eapFeeSchedule.toValueMap().values(), currencyCheck),
|
||||
instance.eapFeeSchedule.toValueMap().values().stream().allMatch(currencyCheck),
|
||||
"All EAP fees must be in the registry's currency");
|
||||
checkArgumentNotNull(
|
||||
instance.pricingEngineClassName, "All registries must have a configured pricing engine");
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.registry.label;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Iterables.partition;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
@ -30,12 +31,11 @@ import static org.joda.time.DateTimeZone.UTC;
|
|||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
import com.googlecode.objectify.Work;
|
||||
|
@ -202,15 +202,9 @@ public final class PremiumListUtils {
|
|||
@VisibleForTesting
|
||||
public static ImmutableSet<PremiumListEntry> parentPremiumListEntriesOnRevision(
|
||||
Iterable<PremiumListEntry> entries, final Key<PremiumListRevision> revisionKey) {
|
||||
return FluentIterable.from(entries)
|
||||
.transform(
|
||||
new Function<PremiumListEntry, PremiumListEntry>() {
|
||||
@Override
|
||||
public PremiumListEntry apply(PremiumListEntry entry) {
|
||||
return entry.asBuilder().setParent(revisionKey).build();
|
||||
}
|
||||
})
|
||||
.toSet();
|
||||
return Streams.stream(entries)
|
||||
.map((PremiumListEntry entry) -> entry.asBuilder().setParent(revisionKey).build())
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
|
||||
/** Deletes the PremiumList and all of its child entities. */
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.model.registry.label;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static google.registry.config.RegistryConfig.getDomainLabelListCacheDuration;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
|
@ -28,14 +29,12 @@ import static google.registry.util.CollectionUtils.nullToEmpty;
|
|||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
|
@ -217,15 +216,10 @@ public final class ReservedList
|
|||
if (label.length() == 0) {
|
||||
return ImmutableSet.of(FULLY_BLOCKED);
|
||||
}
|
||||
return FluentIterable.from(getReservedListEntries(label, tld))
|
||||
.transform(
|
||||
new Function<ReservedListEntry, ReservationType>() {
|
||||
@Override
|
||||
public ReservationType apply(ReservedListEntry reservedListEntry) {
|
||||
return reservedListEntry.reservationType;
|
||||
}
|
||||
})
|
||||
.toSet();
|
||||
return getReservedListEntries(label, tld)
|
||||
.stream()
|
||||
.map((ReservedListEntry reservedListEntry) -> reservedListEntry.reservationType)
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue