mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 03:58:34 +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
|
@ -14,15 +14,13 @@
|
|||
|
||||
package google.registry.model.billing;
|
||||
|
||||
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Maps.EntryTransformer;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.googlecode.objectify.cmd.Query;
|
||||
import google.registry.model.CacheUtils;
|
||||
|
@ -38,19 +36,11 @@ public final class RegistrarBillingUtils {
|
|||
|
||||
private static final Supplier<ImmutableSortedSet<CurrencyUnit>> CURRENCIES_CACHE =
|
||||
CacheUtils.memoizeWithShortExpiration(
|
||||
new Supplier<ImmutableSortedSet<CurrencyUnit>>() {
|
||||
@Override
|
||||
public ImmutableSortedSet<CurrencyUnit> get() {
|
||||
return FluentIterable
|
||||
.from(Registries.getTlds())
|
||||
.transform(new Function<String, CurrencyUnit>() {
|
||||
@Override
|
||||
public CurrencyUnit apply(String tld) {
|
||||
return Registry.get(tld).getCurrency();
|
||||
}})
|
||||
.toSortedSet(Ordering.natural());
|
||||
}
|
||||
});
|
||||
() ->
|
||||
Registries.getTlds()
|
||||
.stream()
|
||||
.map((String tld) -> Registry.get(tld).getCurrency())
|
||||
.collect(toImmutableSortedSet(Ordering.natural())));
|
||||
|
||||
/**
|
||||
* Returns set of currencies in which registrars may be billed.
|
||||
|
@ -69,28 +59,25 @@ public final class RegistrarBillingUtils {
|
|||
*/
|
||||
public static ImmutableMap<CurrencyUnit, Query<RegistrarBillingEntry>> getBillingEntryQueries(
|
||||
final Registrar registrar) {
|
||||
return Maps.toMap(getCurrencies(),
|
||||
new Function<CurrencyUnit, Query<RegistrarBillingEntry>>() {
|
||||
@Override
|
||||
public Query<RegistrarBillingEntry> apply(CurrencyUnit currency) {
|
||||
return ofy().load()
|
||||
return Maps.toMap(
|
||||
getCurrencies(),
|
||||
(CurrencyUnit currency) ->
|
||||
ofy()
|
||||
.load()
|
||||
.type(RegistrarBillingEntry.class)
|
||||
.ancestor(registrar)
|
||||
.filter("currency", currency)
|
||||
.order("-created");
|
||||
}});
|
||||
.order("-created"));
|
||||
}
|
||||
|
||||
/** Returns amount of money registrar currently owes registry in each currency. */
|
||||
public static Map<CurrencyUnit, Money> loadBalance(Registrar registrar) {
|
||||
return Maps.transformEntries(getBillingEntryQueries(registrar),
|
||||
new EntryTransformer<CurrencyUnit, Query<RegistrarBillingEntry>, Money>() {
|
||||
@Override
|
||||
public Money transformEntry(
|
||||
CurrencyUnit currency, Query<RegistrarBillingEntry> query) {
|
||||
RegistrarBillingEntry entry = query.first().now();
|
||||
return entry != null ? entry.getBalance() : Money.zero(currency);
|
||||
}});
|
||||
return Maps.transformEntries(
|
||||
getBillingEntryQueries(registrar),
|
||||
(CurrencyUnit currency, Query<RegistrarBillingEntry> query) -> {
|
||||
RegistrarBillingEntry entry = query.first().now();
|
||||
return entry != null ? entry.getBalance() : Money.zero(currency);
|
||||
});
|
||||
}
|
||||
|
||||
private RegistrarBillingUtils() {}
|
||||
|
|
|
@ -16,15 +16,16 @@ package google.registry.model.billing;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.Registries.assertTldExists;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
|
@ -216,7 +217,8 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
|||
* <p>The resulting list sorts the credits first by type and then by creation time.
|
||||
*/
|
||||
public static ImmutableList<RegistrarCredit> loadAllForRegistrar(Registrar registrar) {
|
||||
return FluentIterable.from(ofy().load().type(RegistrarCredit.class).ancestor(registrar))
|
||||
.toSortedList(CREDIT_PRIORITY_ORDERING);
|
||||
return Streams.stream(ofy().load().type(RegistrarCredit.class).ancestor(registrar))
|
||||
.sorted(CREDIT_PRIORITY_ORDERING)
|
||||
.collect(toImmutableList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ForwardingNavigableMap;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
@ -193,16 +192,12 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
|||
*/
|
||||
@VisibleForTesting
|
||||
BalanceMap(Map<DateTime, ? extends Map<DateTime, Money>> data) {
|
||||
delegate = ImmutableSortedMap.copyOf(
|
||||
Maps.transformValues(
|
||||
data,
|
||||
new Function<Map<DateTime, Money>, ImmutableSortedMap<DateTime, Money>>() {
|
||||
@Override
|
||||
public ImmutableSortedMap<DateTime, Money> apply(Map<DateTime, Money> map) {
|
||||
return ImmutableSortedMap.copyOf(map, Ordering.natural());
|
||||
}
|
||||
}),
|
||||
Ordering.natural());
|
||||
delegate =
|
||||
ImmutableSortedMap.copyOf(
|
||||
Maps.transformValues(
|
||||
data,
|
||||
(Map<DateTime, Money> map) -> ImmutableSortedMap.copyOf(map, Ordering.natural())),
|
||||
Ordering.natural());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue