Package org.pgpainless.key.util
Class UserId
- java.lang.Object
-
- org.pgpainless.key.util.UserId
-
- All Implemented Interfaces:
java.lang.CharSequence
public final class UserId extends java.lang.Object implements java.lang.CharSequence
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UserId.Builder
static class
UserId.DefaultComparator
static class
UserId.DefaultIgnoreCaseComparator
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
asString()
Deprecated.usetoString()
instead.char
charAt(int i)
static int
compare(UserId o1, UserId o2, java.util.Comparator<UserId> comparator)
boolean
equals(java.lang.Object o)
java.lang.String
getComment()
java.lang.String
getEmail()
java.lang.String
getName()
java.lang.String
getName(boolean preserveQuotes)
int
hashCode()
int
length()
static UserId
nameAndEmail(java.lang.String name, java.lang.String email)
static UserId.Builder
newBuilder()
static UserId
onlyEmail(java.lang.String email)
static UserId
parse(java.lang.String string)
Parse aUserId
from free-form text,java.lang.CharSequence
subSequence(int i, int i1)
UserId.Builder
toBuilder()
java.lang.String
toString()
-
-
-
Method Detail
-
parse
public static UserId parse(@Nonnull java.lang.String string)
Parse aUserId
from free-form text,name-addr
ormailbox
string and split it up into its components. Example inputs for this method:[email protected]
<[email protected]>
John Doe
John Doe <[email protected]>
John Doe (work email) <[email protected]>
- Local domains without TLDs (
user@localdomain1
) " "@example.org
(spaces between the quotes)"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
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)
-
newBuilder
public static UserId.Builder newBuilder()
-
toBuilder
public UserId.Builder toBuilder()
-
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 interfacejava.lang.CharSequence
-
charAt
public char charAt(int i)
- Specified by:
charAt
in interfacejava.lang.CharSequence
-
subSequence
@Nonnull public java.lang.CharSequence subSequence(int i, int i1)
- Specified by:
subSequence
in interfacejava.lang.CharSequence
-
toString
@Nonnull public java.lang.String toString()
- Specified by:
toString
in interfacejava.lang.CharSequence
- Overrides:
toString
in classjava.lang.Object
-
asString
@Deprecated public java.lang.String asString()
Deprecated.usetoString()
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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-