mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 08:52:12 +02:00
Switch from Guava Optionals to Java 8 Optionals
This was a surprisingly involved change. Some of the difficulties included java.util.Optional purposely not being Serializable (so I had to move a few Optionals in mapreduce classes to @Nullable) and having to add the Truth Java8 extension library for assertion support. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171863777
This commit is contained in:
parent
184b2b56ac
commit
c0f8da0c6e
581 changed files with 1325 additions and 932 deletions
|
@ -39,7 +39,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import static java.util.Comparator.comparing;
|
||||
import static java.util.function.Predicate.isEqual;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -80,6 +79,7 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -896,13 +896,13 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
|
|||
/** Loads and returns a registrar entity by its client id directly from Datastore. */
|
||||
public static Optional<Registrar> loadByClientId(String clientId) {
|
||||
checkArgument(!Strings.isNullOrEmpty(clientId), "clientId must be specified");
|
||||
return Optional.fromNullable(
|
||||
return Optional.ofNullable(
|
||||
ofy().load().type(Registrar.class).parent(getCrossTldKey()).id(clientId).now());
|
||||
}
|
||||
|
||||
/** Loads and returns a registrar entity by its client id using an in-memory cache. */
|
||||
public static Optional<Registrar> loadByClientIdCached(String clientId) {
|
||||
checkArgument(!Strings.isNullOrEmpty(clientId), "clientId must be specified");
|
||||
return Optional.fromNullable(CACHE_BY_CLIENT_ID.get().get(clientId));
|
||||
return Optional.ofNullable(CACHE_BY_CLIENT_ID.get().get(clientId));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue