Class Username

  • All Implemented Interfaces:
    Identifier, Comparable<Identifier>, net.minidev.json.JSONAware

    public final class Username
    extends BaseIdentifier
    Represents a username.

    The isLegal(java.lang.String) method is intended for basic validation before committing to expensive operations such as authentication. It checks whether the specified string falls outside the typical scope of legal username characters and length.

    • Constructor Detail

      • Username

        public Username​(String value)
        Creates a new username.
        Parameters:
        value - The username value, must not be null. The value is trimmed (of whitespace) internally.
    • Method Detail

      • isLegal

        public static boolean isLegal​(String value)
        Checks whether the specified username value is legal. This is done by performing a regular expression match against LEGAL_USERNAME_RE.
        Parameters:
        value - The username value to test. It is trimmed before testing. Must not be null.
        Returns:
        true if the username is legal, else false.
      • isLegal

        public static boolean isLegal​(String value,
                                      Pattern re)
        Checks whether the specified username value is legal. This is done by performing a regular expression match against the specified regular expression.
        Parameters:
        value - The username value to test. It is trimmed before testing. Must not be null.
        re - The regular expression for validation, must evaluate to true for a legal username value.
        Returns:
        true if the username is legal, else false.
      • equals

        public boolean equals​(Object object)
        Description copied from class: BaseIdentifier
        Overrides Object.equals().
        Specified by:
        equals in class BaseIdentifier
        Parameters:
        object - The object to compare to.
        Returns:
        true if the objects have the same value, otherwise false.