Serializable
, Comparable<Identifier>
, net.minidev.json.JSONAware
@Immutable public final class UserCode extends Identifier
Related specifications:
Modifier and Type | Field | Description |
---|---|---|
static String |
DIGIT_CHAR_SET |
|
static String |
LETTER_CHAR_SET |
DEFAULT_BYTE_LENGTH, secureRandom
Constructor | Description |
---|---|
UserCode() |
Creates a new user code with a randomly generated value with 8
characters from
LETTER_CHAR_SET , in the form
WDJB-MJHT . |
UserCode(String value) |
Creates a new user code with the specified value and the
LETTER_CHAR_SET . |
UserCode(String charset,
int length) |
Creates a new user code with a randomly generated value from the
specified charset and length.
|
UserCode(String value,
String charset) |
Creates a new user code with the specified value.
|
Modifier and Type | Method | Description |
---|---|---|
int |
compareTo(Identifier other) |
|
boolean |
equals(Object object) |
|
String |
getCharset() |
Returns the character set used by this
UserCode . |
String |
getStrippedValue() |
Returns the value with all invalid characters removed.
|
int |
hashCode() |
|
static String |
stripIllegalChars(String value,
String charset) |
Removes all characters from
value that are not in
charset . |
getValue, toJSONString, toString
public static final String LETTER_CHAR_SET
public static final String DIGIT_CHAR_SET
public UserCode(String value, String charset)
value
- The code value. Must not be null
or empty
string.charset
- The character set used by the identifier. The
identifier can only contain characters from this set.
If null
, all characters are allowed.public UserCode(String value)
LETTER_CHAR_SET
.value
- The code value. Must not be null
or empty
string.public UserCode()
LETTER_CHAR_SET
, in the form
WDJB-MJHT
.public String getCharset()
UserCode
.null
if unspecified.public String getStrippedValue()
public int compareTo(Identifier other)
compareTo
in interface Comparable<Identifier>
compareTo
in class Identifier
public int hashCode()
hashCode
in class Identifier
public boolean equals(Object object)
equals
in class Identifier
public static String stripIllegalChars(String value, String charset)
value
that are not in
charset
.value
- The code value.charset
- The allowed characters in value
. If
null
all characters are retained.value
with all invalid characters removed.Copyright © 2019 Connect2id Ltd.. All rights reserved.