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 boolean
Does the username conforms to an email address format.private final String
Username. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Username
(IUsernameStrategy validationStrategy, String username) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
Compare with another object.boolean
Is equal with another object.int
hashCode()
Calculate hash code.boolean
isEMail()
Is username an email address.static Username
of
(IUsernameStrategy validationStrategy, String username) Username factory.static Username
Username 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:
stringValue
in 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:
compareTo
in interfaceComparable<Username>
- Parameters:
obj
- Object to compare with- Returns:
- 0: equal; 1: greater; -1: smaller
- See Also:
-