Class User.Name
- All Implemented Interfaces:
DtoFactory<UserName>
,FastExternalizable
,Internable<User.Name>
,Externalizable
,Serializable
,Comparable<User.Name>
- Direct Known Subclasses:
User.Name
- Enclosing class:
User
- Be non-null
- Be non-empty
- Be between 1 and 255 characters
- Must start with
[a-z]
- Uses only ASCII 0x21 through 0x7f, excluding
space , : ( ) [ ] ' " | & ; A-Z \ /
- If contains any @ symbol, must also be a valid email address. Please note that the reverse is not implied - email addresses may exist that are not valid user ids.
TODO: Should we allow Unicode here, since we now have a more restrictive User.Name
for shell accounts?
- Author:
- AO Industries, Inc.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTH- See Also:
-
name
-
-
Constructor Details
-
Name
- Throws:
ValidationException
-
Name
- Parameters:
name
- Does not validate, should only be used with a known valid value.
-
Name
Deprecated.Only required for implementation, do not use directly.- See Also:
-
-
Method Details
-
validate
Validates aUser
name. -
valueOf
- Parameters:
name
- whennull
, returnsnull
- Throws:
ValidationException
-
validate
- Throws:
ValidationException
-
equals
-
hashCode
public final int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<User.Name>
-
toString
-
intern
Interns this name much in the same fashion asString.intern()
.Because this has subtypes, two
User.Name
that areequals(java.lang.Object)
may not necessarily return the same instance object after interning. Thus, unless you know objects are of the same class,equals(java.lang.Object)
should still be used for equality check instead of theobj1 == obj2
shortcut.To more efficiently check post-interned equivalence, one could also do
obj1 == obj2 || (obj1.getClass() != obj2.getClass() && obj1.equals(obj2))
, but is it worth it?And then if we abuse the fact that interned user ids have an interned name, one could check equivalence of post-interned user ids as
obj1.getId() == obj2.getId()
, but once again, is it worth it? Just callequals(java.lang.Object)
.- Specified by:
intern
in interfaceInternable<User.Name>
- See Also:
-
getDto
- Specified by:
getDto
in interfaceDtoFactory<UserName>
-
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
-