Improve documentation of TLD extraction routines

Some confusion came up in #9 over the proper way to extract TLDs from
hostnames. This should hopefully alleviate that.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=118417091
This commit is contained in:
jart 2016-03-28 18:12:09 -07:00 committed by Justine Tunney
parent ec2daec412
commit 4442f4c31b
2 changed files with 20 additions and 5 deletions

View file

@ -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.
*
* <p><b>Note:</b> 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<InternetDomainName> findTldForName(InternetDomainName domainName) {
ImmutableSet<String> tlds = getTlds();