java.lang.Object
com.aoapps.net.HostAddress
- All Implemented Interfaces:
DtoFactory<HostAddress>
,Internable<HostAddress>
,Serializable
,Comparable<HostAddress>
public final class HostAddress
extends Object
implements Comparable<HostAddress>, Serializable, DtoFactory<HostAddress>, Internable<HostAddress>
Represents a host's address as either a
DomainName
or an InetAddress
.
To not allow the IP address representation, use DomainName
instead.
No DNS lookups are performed during validation.- Author:
- AO Industries, Inc.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(HostAddress other) Sorts IP addresses before domain names.boolean
getDto()
int
hashCode()
intern()
Interns this host address much in the same fashion asString.intern()
.toString()
static ValidationResult
Validates a host address, must be either a valid domain name or a valid IP address.static HostAddress
valueOf
(DomainName domainName) If domainName is null, returns null.static HostAddress
valueOf
(InetAddress ip) If ip is null, returns null.static HostAddress
When enclosed in brackets"[...]"
-
Method Details
-
validate
Validates a host address, must be either a valid domain name or a valid IP address.When enclosed in brackets
"[...]"
, will be validated as an IPv6InetAddress
(seetoBracketedString()
).TODO: Must be non-arpa
-
valueOf
- Parameters:
address
- whennull
, returnsnull
- Throws:
ValidationException
-
valueOf
If domainName is null, returns null. -
valueOf
If ip is null, returns null. -
equals
-
hashCode
public int hashCode() -
compareTo
Sorts IP addresses before domain names.- Specified by:
compareTo
in interfaceComparable<HostAddress>
-
toString
-
toBracketedString
-
intern
Interns this host address much in the same fashion asString.intern()
.- Specified by:
intern
in interfaceInternable<HostAddress>
- See Also:
-
getDomainName
-
getInetAddress
-
getDto
- Specified by:
getDto
in interfaceDtoFactory<HostAddress>
-