diff --git a/java/com/google/domain/registry/model/domain/DomainUtils.java b/java/com/google/domain/registry/model/domain/DomainUtils.java index d9220fce6..b3931a911 100644 --- a/java/com/google/domain/registry/model/domain/DomainUtils.java +++ b/java/com/google/domain/registry/model/domain/DomainUtils.java @@ -20,16 +20,21 @@ import com.google.common.base.Strings; import com.google.common.net.InternetDomainName; /** - * Contains static utility methods for dealing with domains. + * Utility class for dealing with domains. */ -public class DomainUtils { +public final class DomainUtils { /** * Returns the canonicalized TLD part of a valid domain name (just an SLD, no subdomains) by * stripping off the leftmost part. * - *
This function is compatible with multi-part tlds. + *
This function is compatible with multi-part tlds, e.g. {@code co.uk}. This function will + * also work on domains for which the registry is not authoritative. If you are certain that the + * input will be under a TLD this registry controls, then it is preferable to use + * {@link com.google.domain.registry.model.registry.Registries#findTldForName(InternetDomainName) + * Registries#findTldForName}, which will work on hostnames in addition to domains. * + * @param fullyQualifiedDomainName must be a punycode SLD (not a host or unicode) * @throws IllegalArgumentException if there is no TLD */ public static String getTldFromDomainName(String fullyQualifiedDomainName) { @@ -40,4 +45,6 @@ public class DomainUtils { checkArgument(domainName.hasParent(), "fullyQualifiedDomainName does not have a TLD"); return domainName.parent().toString(); } + + private DomainUtils() {} } diff --git a/java/com/google/domain/registry/model/registry/Registries.java b/java/com/google/domain/registry/model/registry/Registries.java index 21bf9b63d..6758bf075 100644 --- a/java/com/google/domain/registry/model/registry/Registries.java +++ b/java/com/google/domain/registry/model/registry/Registries.java @@ -86,8 +86,16 @@ public final class Registries { } /** - * Returns the TLD which the domain name or hostname falls under, no matter how many levels of - * subdomains there are. + * Returns TLD which the domain name or hostname falls under, no matter how many levels of + * sublabels there are. + * + *
Note: This routine will only work on names under TLDs for which this registry is
+ * authoritative. To extract TLDs from domains (not hosts) that other registries control, use
+ * {@link com.google.domain.registry.model.domain.DomainUtils#getTldFromDomainName(String)
+ * DomainUtils#getTldFromDomainName}.
+ *
+ * @param domainName domain name or host name (but not TLD) under an authoritative TLD
+ * @return TLD or absent if {@code domainName} has no labels under an authoritative TLD
*/
public static Optional