Class EmailAddress


  • public class EmailAddress
    extends Object
    represent a mail address with an email address part and an optional full name e.g.
    [email protected]
    [email protected] (This User)
    Another User <[email protected]>
    "display(name)" <[email protected]>

    the constructor will validate the address catching format errors like excess spaces, newlines the test is not very strict, for example an IDN address will be considered valid, even though SMTP doesn't work with that yet

    Author:
    Alexander Lehmann
    • Constructor Detail

      • EmailAddress

        public EmailAddress​(String fullAddress)
        parse and create an email address
        Parameters:
        fullAddress - full address string
        Throws:
        IllegalArgumentException - if an address is not valid
    • Method Detail

      • getEmail

        public String getEmail()
        get the email part of the address
        Returns:
        the email
      • getName

        public String getName()
        get the name part of the address
        Returns:
        the full name
      • toString

        public String toString()
        get a representation of the address (this is mostly for testing)
        Overrides:
        toString in class Object
        Returns:
        representation of the address