mirror of
https://github.com/google/nomulus
synced 2026-09-05 23:57:01 +00: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:
@@ -17,11 +17,11 @@ package google.registry.tldconfig.idn;
|
||||
import static google.registry.tldconfig.idn.IdnTableEnum.EXTENDED_LATIN;
|
||||
import static google.registry.tldconfig.idn.IdnTableEnum.JA;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.util.Idn;
|
||||
import google.registry.util.NonFinalForTesting;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Validates whether a given IDN label can be provisioned for a particular TLD. */
|
||||
public final class IdnLabelValidator {
|
||||
@@ -44,12 +44,12 @@ public final class IdnLabelValidator {
|
||||
public static Optional<String> findValidIdnTableForTld(String label, String tld) {
|
||||
String unicodeString = Idn.toUnicode(label);
|
||||
for (IdnTableEnum idnTable
|
||||
: Optional.fromNullable(idnTableListsPerTld.get(tld)).or(DEFAULT_IDN_TABLES)) {
|
||||
: Optional.ofNullable(idnTableListsPerTld.get(tld)).orElse(DEFAULT_IDN_TABLES)) {
|
||||
if (idnTable.getTable().isValidLabel(unicodeString)) {
|
||||
return Optional.of(idnTable.getTable().getName());
|
||||
}
|
||||
}
|
||||
return Optional.absent();
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private IdnLabelValidator() {}
|
||||
|
||||
Reference in New Issue
Block a user