java.lang.Object
com.aoapps.net.Email
- All Implemented Interfaces:
DtoFactory<Email>
,FastExternalizable
,Internable<Email>
,Externalizable
,Serializable
,Comparable<Email>
,SQLData
public final class Email
extends Object
implements Comparable<Email>, FastExternalizable, DtoFactory<Email>, Internable<Email>, SQLData
Represents an email address. Email addresses must:
- Be non-null
- Be non-empty
- Contain a single @, but not at the beginning or end
- Local part must adhere to RFC 5322.
- Author:
- AO Industries, Inc.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Sorts by domain and then by local part.boolean
getDto()
long
int
hashCode()
intern()
Interns this email much in the same fashion asString.intern()
.void
void
toString()
static ValidationResult
Validates a complete email address.static ValidationResult
validate
(String localPart, DomainName domain) Validates the local part of the email address (before the @ symbol), as well as additional domain rules.static ValidationResult
Validates the local part of the email address (before the @ symbol), as well as additional domain rules.static Email
static Email
valueOf
(String localPart, DomainName domain) void
void
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTH- See Also:
-
MAX_LOCAL_PART_LENGTH
public static final int MAX_LOCAL_PART_LENGTH- See Also:
-
SQL_TYPE
- See Also:
-
-
Constructor Details
-
Email
Deprecated.Only required for implementation, do not use directly.- See Also:
-
-
Method Details
-
validate
Validates a complete email address. Splits on @ and callsvalidate
on local part and domain.- See Also:
-
validate
Validates the local part of the email address (before the @ symbol), as well as additional domain rules. -
validate
Validates the local part of the email address (before the @ symbol), as well as additional domain rules. -
valueOf
- Parameters:
email
- whennull
, returnsnull
- Throws:
ValidationException
- See Also:
-
valueOf
- Throws:
ValidationException
-
equals
-
hashCode
public int hashCode() -
compareTo
Sorts by domain and then by local part.- Specified by:
compareTo
in interfaceComparable<Email>
-
toString
-
intern
Interns this email much in the same fashion asString.intern()
.- Specified by:
intern
in interfaceInternable<Email>
- See Also:
-
getLocalPart
-
getDomain
-
getDto
- Specified by:
getDto
in interfaceDtoFactory<Email>
-
getSerialVersionUID
public long getSerialVersionUID()- Specified by:
getSerialVersionUID
in interfaceFastExternalizable
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
getSQLTypeName
- Specified by:
getSQLTypeName
in interfaceSQLData
-
writeSQL
- Specified by:
writeSQL
in interfaceSQLData
- Throws:
SQLException
-
readSQL
- Specified by:
readSQL
in interfaceSQLData
- Throws:
SQLException
-