Class User.Name
- java.lang.Object
-
- com.aoindustries.aoserv.client.account.User.Name
-
- All Implemented Interfaces:
DtoFactory<UserName>,FastExternalizable,Internable<User.Name>,Externalizable,Serializable,Comparable<User.Name>
- Direct Known Subclasses:
User.Name
- Enclosing class:
- User
public static class User.Name extends Object implements Comparable<User.Name>, FastExternalizable, DtoFactory<UserName>, Internable<User.Name>
Represents the most general form of a user name. This is has the fewest constraints; other types of accounts constrain this further. User names must:- 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.Namefor shell accounts?- Author:
- AO Industries, Inc.
- See Also:
User.Name,User.Name,User.Name, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_LENGTHprotected Stringname
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(User.Name other)booleanequals(Object O)UserNamegetDto()longgetSerialVersionUID()inthashCode()User.Nameintern()Interns this name much in the same fashion asString.intern().voidreadExternal(ObjectInput in)StringtoString()protected voidvalidate()static ValidationResultvalidate(String name)Validates aUsername.static User.NamevalueOf(String name)voidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
MAX_LENGTH
public static final int MAX_LENGTH
- See Also:
- Constant Field Values
-
name
protected String name
-
-
Constructor Detail
-
Name
protected Name(String name, boolean validate) throws ValidationException
- Throws:
ValidationException
-
Name
protected Name(String name)
- Parameters:
name- Does not validate, should only be used with a known valid value.
-
Name
public Name()
-
-
Method Detail
-
validate
public static ValidationResult validate(String name)
Validates aUsername.
-
valueOf
public static User.Name valueOf(String name) throws ValidationException
- Parameters:
name- whennull, returnsnull- Throws:
ValidationException
-
validate
protected void validate() throws ValidationException- Throws:
ValidationException
-
compareTo
public final int compareTo(User.Name other)
- Specified by:
compareToin interfaceComparable<User.Name>
-
intern
public User.Name intern()
Interns this name much in the same fashion asString.intern().Because this has subtypes, two
User.Namethat 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 == obj2shortcut.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:
internin interfaceInternable<User.Name>- See Also:
String.intern()
-
getDto
public UserName getDto()
- Specified by:
getDtoin interfaceDtoFactory<UserName>
-
getSerialVersionUID
public long getSerialVersionUID()
- Specified by:
getSerialVersionUIDin interfaceFastExternalizable
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-