mirror of
https://github.com/google/nomulus.git
synced 2025-07-12 14:08:18 +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
|
@ -16,15 +16,12 @@ package google.registry.whois;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.Iterables.tryFind;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||
import static google.registry.xml.UtcDateTimeAdapter.getFormattedString;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.contact.ContactPhoneNumber;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -39,6 +36,7 @@ import google.registry.model.registrar.RegistrarContact;
|
|||
import google.registry.model.translators.EnumToAttributeAdapter.EppEnum;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -74,8 +72,11 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
domain.getCurrentSponsorClientId());
|
||||
Registrar registrar = registrarOptional.get();
|
||||
Optional<RegistrarContact> abuseContact =
|
||||
Iterables.tryFind(
|
||||
registrar.getContacts(), RegistrarContact::getVisibleInDomainWhoisAsAbuse);
|
||||
registrar
|
||||
.getContacts()
|
||||
.stream()
|
||||
.filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse)
|
||||
.findFirst();
|
||||
String plaintext =
|
||||
new DomainEmitter()
|
||||
.emitField(
|
||||
|
@ -121,7 +122,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
@Nullable
|
||||
private Key<ContactResource> getContactReference(final Type type) {
|
||||
Optional<DesignatedContact> contactOfType =
|
||||
tryFind(domain.getContacts(), d -> d.getType() == type);
|
||||
domain.getContacts().stream().filter(d -> d.getType() == type).findFirst();
|
||||
return contactOfType.isPresent() ? contactOfType.get().getContactKey() : null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue