java.lang.Object
de.powerstat.validation.values.Username
All Implemented Interfaces:
IValueObject, Comparable<Username>

public final class Username extends Object implements Comparable<Username>, IValueObject
Username. DSGVO relevant. TODO Already existing user? TODO case sensitive or insensitive? TODO Comparable<EMail>
  • Field Details

    • username

      private final String username
      Username.
    • conformsToEMailAddressFormat

      private final boolean conformsToEMailAddressFormat
      Does the username conforms to an email address format.
  • Constructor Details

    • Username

      private Username(IUsernameStrategy validationStrategy, String username)
      Constructor.
      Parameters:
      validationStrategy - Validation strategy
      username - Username
      Throws:
      NullPointerException - if username or validationStrategy is null
      IllegalArgumentException - if username contains unsupported characters or is to long or short
  • Method Details

    • of

      public static Username of(IUsernameStrategy validationStrategy, String username)
      Username factory.
      Parameters:
      validationStrategy - Validation strategy
      username - Username
      Returns:
      Username object
    • of

      public static Username of(String username)
      Username factory with UsernameMin2Max254CanBeEMailStrategy.
      Parameters:
      username - Username
      Returns:
      Username object
    • stringValue

      public String stringValue()
      Returns the value of this Username as a string.
      Specified by:
      stringValue in interface IValueObject
      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.
      Overrides:
      hashCode in class Object
      Returns:
      Hash
      See Also:
    • equals

      public boolean equals(Object obj)
      Is equal with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - Object
      Returns:
      true when equal, false otherwise
      See Also:
    • toString

      public String 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]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Username
      See Also:
    • compareTo

      public int compareTo(Username obj)
      Compare with another object.
      Specified by:
      compareTo in interface Comparable<Username>
      Parameters:
      obj - Object to compare with
      Returns:
      0: equal; 1: greater; -1: smaller
      See Also: