Class EmailValidator

  • All Implemented Interfaces:
    Validator<java.lang.String>

    public class EmailValidator
    extends java.lang.Object
    implements Validator<java.lang.String>
    Validates email format.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EMAIL_FORMAT_REGEX
      Regular expression to validate email format.
      private java.util.regex.Pattern mEmailPattern
      Pattern to validate email addresses using regular expression defined in EMAIL_FORMAT_REGEX.
      private static java.lang.ref.SoftReference<EmailValidator> mSingleton
      Soft reference to the singleton of this class.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private EmailValidator()
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static EmailValidator getInstance()
      Creates or obtains the singleton instance of this class.
      boolean isValid​(java.lang.String email)
      Indicates whether provided email has a valid format.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMAIL_FORMAT_REGEX

        public static final java.lang.String EMAIL_FORMAT_REGEX
        Regular expression to validate email format.
        See Also:
        Constant Field Values
      • mSingleton

        private static java.lang.ref.SoftReference<EmailValidator> mSingleton
        Soft reference to the singleton of this class.
      • mEmailPattern

        private final java.util.regex.Pattern mEmailPattern
        Pattern to validate email addresses using regular expression defined in EMAIL_FORMAT_REGEX.
    • Constructor Detail

      • EmailValidator

        private EmailValidator()
        Constructor.
    • Method Detail

      • getInstance

        public static EmailValidator getInstance()
        Creates or obtains the singleton instance of this class.
        Returns:
        singleton instance of this class.
      • isValid

        public boolean isValid​(java.lang.String email)
        Indicates whether provided email has a valid format.
        Specified by:
        isValid in interface Validator<java.lang.String>
        Parameters:
        email - email to be checked.
        Returns:
        true if email is valid, false otherwise.