Class UserId

  • All Implemented Interfaces:
    java.lang.CharSequence

    public final class UserId
    extends java.lang.Object
    implements java.lang.CharSequence
    • Method Detail

      • parse

        public static UserId parse​(@Nonnull
                                   java.lang.String string)
        Parse a UserId from free-form text,
        name-addr
        or
        mailbox
        string and split it up into its components. Example inputs for this method: In these cases, this method will detect email addresses, names and comments and expose those via the respective getters. This method does not support parsing mail addresses of the following formats:
        • Local domains without TLDs (
          user@localdomain1
          )
        • " "@example.org
          (spaces between the quotes)
        • "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
        Note: This method does not guarantee that
        string.equals(UserId.parse(string).toString())
        is true. For example,
        UserId.parse("[email protected]").toString()
        wraps the mail address in angled brackets.
        Parameters:
        string - user-id
        Returns:
        parsed UserId object
        See Also:
        RFC5322 ยง3.4. Address Specification
      • onlyEmail

        public static UserId onlyEmail​(@Nonnull
                                       java.lang.String email)
      • nameAndEmail

        public static UserId nameAndEmail​(@Nonnull
                                          java.lang.String name,
                                          @Nonnull
                                          java.lang.String email)
      • getName

        public java.lang.String getName()
      • getName

        public java.lang.String getName​(boolean preserveQuotes)
      • getComment

        public java.lang.String getComment()
      • getEmail

        public java.lang.String getEmail()
      • length

        public int length()
        Specified by:
        length in interface java.lang.CharSequence
      • charAt

        public char charAt​(int i)
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

        @Nonnull
        public java.lang.CharSequence subSequence​(int i,
                                                  int i1)
        Specified by:
        subSequence in interface java.lang.CharSequence
      • toString

        @Nonnull
        public java.lang.String toString()
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object
      • asString

        @Deprecated
        public java.lang.String asString()
        Deprecated.
        use toString() instead.
        Returns a string representation of the object.
        Returns:
        a string representation of the object.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compare

        public static int compare​(@Nullable
                                  UserId o1,
                                  @Nullable
                                  UserId o2,
                                  @Nonnull
                                  java.util.Comparator<UserId> comparator)