mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Replace com.google.common.base.Function with java.util.function.Function
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179249159
This commit is contained in:
parent
d538dca2e0
commit
8157928a35
53 changed files with 424 additions and 399 deletions
|
@ -15,10 +15,9 @@
|
|||
package google.registry.model.ofy;
|
||||
|
||||
import static com.googlecode.objectify.ObjectifyService.ofy;
|
||||
import static google.registry.util.ObjectifyUtils.OBJECTS_TO_KEYS;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Result;
|
||||
|
@ -38,13 +37,13 @@ abstract class AugmentedDeleter implements Deleter {
|
|||
|
||||
@Override
|
||||
public Result<Void> entities(Iterable<?> entities) {
|
||||
handleDeletion(Iterables.transform(entities, OBJECTS_TO_KEYS));
|
||||
handleDeletion(Iterables.transform(entities, Key::create));
|
||||
return delegate.entities(entities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Void> entities(Object... entities) {
|
||||
handleDeletion(FluentIterable.from(entities).transform(OBJECTS_TO_KEYS));
|
||||
handleDeletion(FluentIterable.from(entities).transform(Key::create));
|
||||
return delegate.entities(entities);
|
||||
}
|
||||
|
||||
|
@ -65,11 +64,8 @@ abstract class AugmentedDeleter implements Deleter {
|
|||
// Magic to convert the type Iterable<? extends Key<?>> (a family of types which allows for
|
||||
// homogeneous iterables of a fixed Key<T> type, e.g. List<Key<Lock>>, and is convenient for
|
||||
// callers) into the type Iterable<Key<?>> (a concrete type of heterogeneous keys, which is
|
||||
// convenient for users). We do this by passing each key through the identity function
|
||||
// parameterized for Key<?>, which erases any homogeneous typing on the iterable.
|
||||
// See: http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeArguments.html#FAQ104
|
||||
Iterable<Key<?>> retypedKeys = Iterables.transform(keys, Functions.<Key<?>>identity());
|
||||
handleDeletion(retypedKeys);
|
||||
// convenient for users).
|
||||
handleDeletion(ImmutableList.<Key<?>>copyOf(keys));
|
||||
return delegate.keys(keys);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import static google.registry.model.ofy.CommitLogBucket.loadBucket;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
@ -153,9 +152,7 @@ class CommitLoggedWork<R> extends VoidWork {
|
|||
mutations =
|
||||
union(info.getSaves(), untouchedRootsWithTouchedChildren)
|
||||
.stream()
|
||||
.map(
|
||||
(Function<Object, ImmutableObject>)
|
||||
(Object saveEntity) -> CommitLogMutation.create(manifestKey, saveEntity))
|
||||
.map(entity -> (ImmutableObject) CommitLogMutation.create(manifestKey, entity))
|
||||
.collect(toImmutableSet());
|
||||
ofy().saveWithoutBackup()
|
||||
.entities(new ImmutableSet.Builder<>()
|
||||
|
|
|
@ -21,7 +21,6 @@ import static com.google.common.collect.Maps.uniqueIndex;
|
|||
import static com.googlecode.objectify.ObjectifyService.ofy;
|
||||
import static google.registry.config.RegistryConfig.getBaseOfyRetryDuration;
|
||||
import static google.registry.util.CollectionUtils.union;
|
||||
import static google.registry.util.ObjectifyUtils.OBJECTS_TO_KEYS;
|
||||
|
||||
import com.google.appengine.api.datastore.DatastoreFailureException;
|
||||
import com.google.appengine.api.datastore.DatastoreTimeoutException;
|
||||
|
@ -170,7 +169,7 @@ public class Ofy {
|
|||
assertInTransaction();
|
||||
checkState(Streams.stream(entities).allMatch(notNull()), "Can't save a null entity.");
|
||||
checkProhibitedAnnotations(entities, NotBackedUp.class, VirtualEntity.class);
|
||||
ImmutableMap<Key<?>, ?> keysToEntities = uniqueIndex(entities, OBJECTS_TO_KEYS);
|
||||
ImmutableMap<Key<?>, ?> keysToEntities = uniqueIndex(entities, Key::create);
|
||||
TRANSACTION_INFO.get().putSaves(keysToEntities);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
package google.registry.model.ofy;
|
||||
|
||||
import static com.google.common.base.Functions.constant;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Maps.filterValues;
|
||||
|
@ -76,7 +75,7 @@ class TransactionInfo {
|
|||
|
||||
void putDeletes(Iterable<Key<?>> keys) {
|
||||
assertNotReadOnly();
|
||||
changesBuilder.putAll(toMap(keys, constant(TransactionInfo.Delete.SENTINEL)));
|
||||
changesBuilder.putAll(toMap(keys, k -> TransactionInfo.Delete.SENTINEL));
|
||||
}
|
||||
|
||||
ImmutableSet<Key<?>> getTouchedKeys() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue