public class EnumFieldType extends NullSafeType<EnumValue>
FieldType
for EnumValue
, which is the data type used by
EnumField
.
Each EnumFieldType
instance has an ordered list of String
identifiers; two EnumFieldType
instances are not compatible unless they have identical identifier lists. The identifiers must be valid Java identifiers.
Note that whatever Enum
type may be used to represent values at the Java layer is unimportant;
only the ordered list of identifiers matters.
Null values are supported by this class.
Modifier and Type | Field and Description |
---|---|
static String |
IDENT_PATTERN |
inner, NOT_NULL_SENTINEL, NULL_SENTINEL
name, NAME_PATTERN, REFERENCE_TYPE_NAME, signature, typeToken
Constructor and Description |
---|
EnumFieldType(Class<T> enumType)
Constructor that derives the type name and identifier list from the given
Enum type. |
EnumFieldType(List<String> idents)
Primary constructor.
|
Modifier and Type | Method and Description |
---|---|
List<String> |
getIdentifiers()
Get the identifiers associated with this instance in ordinal order.
|
static Map<String,EnumValue> |
validateIdentifiers(List<String> idents)
Validate a list of enum identifiers and build a mapping from identifier to corresponding
EnumValue . |
compare, convert, equals, fromParseableString, fromString, genericizeForIndex, getInnerType, hashCode, hasPrefix0x00, hasPrefix0xff, read, skip, toParseableString, toString, write
getDefaultValue, getDefaultValueObject, getEncodingSignature, getKeyRange, getName, getTypeToken, toString, validate, validateAndWrite
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public static final String IDENT_PATTERN
public EnumFieldType(Class<T> enumType)
Enum
type.T
- enum typeenumType
- Java Enum
type from which to derive type name and ordered identifier listNullPointerException
- if enumType
is nullpublic EnumFieldType(List<String> idents)
idents
- ordered list of identifiersIllegalArgumentException
- if name
is null or invalidIllegalArgumentException
- if idents
is null or contains a duplicate or invalid identifierpublic List<String> getIdentifiers()
public static Map<String,EnumValue> validateIdentifiers(List<String> idents)
EnumValue
.
The returned mapping will iterate the EnumValue
s in ordinal order.idents
- enum identifiersEnumValue
IllegalArgumentException
- if idents
is nullIllegalArgumentException
- if any identifier in idents
is null, duplicate, or not a valid Java identifierCopyright © 2022. All rights reserved.