java.lang.Object
de.powerstat.validation.values.Username
- All Implemented Interfaces:
IValueObject,Comparable<Username>
Username.
DSGVO relevant.
TODO Already existing user?
TODO case sensitive or insensitive?
TODO Comparable<EMail>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanDoes the username conforms to an email address format.private final StringUsername. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateUsername(IUsernameStrategy validationStrategy, String username) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintCompare with another object.booleanIs equal with another object.inthashCode()Calculate hash code.booleanisEMail()Is username an email address.static Usernameof(IUsernameStrategy validationStrategy, String username) Username factory.static UsernameUsername factory with UsernameMin2Max254CanBeEMailStrategy.Returns the value of this Username as a string.toString()Returns the string representation of this Username.
-
Field Details
-
username
Username. -
conformsToEMailAddressFormat
private final boolean conformsToEMailAddressFormatDoes the username conforms to an email address format.
-
-
Constructor Details
-
Username
Constructor.- Parameters:
validationStrategy- Validation strategyusername- Username- Throws:
NullPointerException- if username or validationStrategy is nullIllegalArgumentException- if username contains unsupported characters or is to long or short
-
-
Method Details
-
of
Username factory.- Parameters:
validationStrategy- Validation strategyusername- Username- Returns:
- Username object
-
of
Username factory with UsernameMin2Max254CanBeEMailStrategy.- Parameters:
username- Username- Returns:
- Username object
-
stringValue
Returns the value of this Username as a string.- Specified by:
stringValuein interfaceIValueObject- Returns:
- The text value represented by this object after conversion to type string.
-
isEMail
public boolean isEMail()Is username an email address.- Returns:
- true when username is an email address, false otherwise
-
hashCode
public int hashCode()Calculate hash code. -
equals
Is equal with another object. -
toString
Returns the string representation of this Username. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Username[username=user@example.com]" -
compareTo
Compare with another object.- Specified by:
compareToin interfaceComparable<Username>- Parameters:
obj- Object to compare with- Returns:
- 0: equal; 1: greater; -1: smaller
- See Also:
-