public class EnumResolver extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected Enum<?> |
_defaultValue |
protected Class<Enum<?>> |
_enumClass |
protected Enum<?>[] |
_enums |
protected HashMap<String,Enum<?>> |
_enumsById |
protected boolean |
_isFromIntValue
Marker for case where value may come from
@JsonValue annotated
accessor and is expected/likely to come from actual integral number
value (and not String). |
protected boolean |
_isIgnoreCase
Marker for case-insensitive handling
|
Modifier | Constructor and Description |
---|---|
protected |
EnumResolver(Class<Enum<?>> enumClass,
Enum<?>[] enums,
HashMap<String,Enum<?>> map,
Enum<?> defaultValue,
boolean isIgnoreCase,
boolean isFromIntValue) |
Modifier and Type | Method and Description |
---|---|
protected static Class<Enum<?>> |
_enumClass(Class<?> enumCls0) |
protected static Enum<?>[] |
_enumConstants(Class<?> enumCls) |
protected static Enum<?> |
_enumDefault(AnnotationIntrospector intr,
AnnotatedClass annotatedClass,
Enum<?>[] enums)
Internal helper method used to resolve Enum default value to use (if any).
|
protected static Enum<?> |
_enumDefault(AnnotationIntrospector intr,
Class<?> enumCls)
Deprecated.
Since 2.16. Use
_enumDefault(AnnotationIntrospector, AnnotatedClass, Enum[]) instead. |
protected Enum<?> |
_findEnumCaseInsensitive(String key) |
protected static boolean |
_isIntType(Class<?> erasedType) |
static EnumResolver |
constructFor(DeserializationConfig config,
AnnotatedClass annotatedClass)
Factory method for constructing an
EnumResolver based on the given DeserializationConfig and
AnnotatedClass of the enum to be resolved. |
static EnumResolver |
constructFor(DeserializationConfig config,
Class<?> enumCls0)
Deprecated.
Since 2.16 use
constructFor(DeserializationConfig, AnnotatedClass) instead |
CompactStringObjectMap |
constructLookup() |
static EnumResolver |
constructUsingEnumNamingStrategy(DeserializationConfig config,
AnnotatedClass annotatedClass,
EnumNamingStrategy enumNamingStrategy)
Factory method for constructing an
EnumResolver with EnumNamingStrategy applied. |
static EnumResolver |
constructUsingEnumNamingStrategy(DeserializationConfig config,
Class<?> enumCls0,
EnumNamingStrategy enumNamingStrategy)
Deprecated.
|
static EnumResolver |
constructUsingIndex(DeserializationConfig config,
AnnotatedClass annotatedClass)
Factory method for constructing resolver that maps from index of Enum.values() into
Enum value.
|
static EnumResolver |
constructUsingIndex(DeserializationConfig config,
Class<Enum<?>> enumCls0)
Deprecated.
Since 2.16. Use
constructUsingIndex(DeserializationConfig, AnnotatedClass) instead. |
static EnumResolver |
constructUsingMethod(DeserializationConfig config,
AnnotatedClass annotatedClass,
AnnotatedMember accessor)
Method used when actual String serialization is indicated using @JsonValue
on a method in Enum class.
|
static EnumResolver |
constructUsingMethod(DeserializationConfig config,
Class<?> enumCls0,
AnnotatedMember accessor)
Deprecated.
Since 2.16.
Use
constructUsingMethod(DeserializationConfig, AnnotatedClass, AnnotatedMember) instead. |
static EnumResolver |
constructUsingToString(DeserializationConfig config,
AnnotatedClass annotatedClass)
Factory method for constructing resolver that maps from Enum.toString() into
Enum value
|
static EnumResolver |
constructUsingToString(DeserializationConfig config,
Class<?> enumCls0)
Deprecated.
Since 2.16 use
constructUsingToString(DeserializationConfig, AnnotatedClass) instead |
Enum<?> |
findEnum(String key) |
Enum<?> |
getDefaultValue() |
Enum<?> |
getEnum(int index) |
Class<Enum<?>> |
getEnumClass() |
Collection<String> |
getEnumIds() |
List<Enum<?>> |
getEnums() |
Enum<?>[] |
getRawEnums() |
boolean |
isFromIntValue()
Accessor for checking if we have a special case in which value to map
is from
@JsonValue annotated accessor with integral type: this
matters for cases where incoming content value is of integral type
and should be mapped to specific value and NOT to Enum.index() . |
int |
lastValidIndex() |
protected final Enum<?>[] _enums
protected final Enum<?> _defaultValue
protected final boolean _isIgnoreCase
protected final boolean _isFromIntValue
@JsonValue
annotated
accessor and is expected/likely to come from actual integral number
value (and not String).
Special case is needed since this specifically means that Enum.index()
should NOT be used or default to.
public static EnumResolver constructFor(DeserializationConfig config, AnnotatedClass annotatedClass)
EnumResolver
based on the given DeserializationConfig
and
AnnotatedClass
of the enum to be resolved.config
- the deserialization configuration to useannotatedClass
- the annotated class of the enum to be resolvedEnumResolver
@Deprecated public static EnumResolver constructFor(DeserializationConfig config, Class<?> enumCls0)
constructFor(DeserializationConfig, AnnotatedClass)
insteadpublic static EnumResolver constructUsingToString(DeserializationConfig config, AnnotatedClass annotatedClass)
@Deprecated public static EnumResolver constructUsingToString(DeserializationConfig config, Class<?> enumCls0)
constructUsingToString(DeserializationConfig, AnnotatedClass)
insteadpublic static EnumResolver constructUsingIndex(DeserializationConfig config, AnnotatedClass annotatedClass)
@Deprecated public static EnumResolver constructUsingIndex(DeserializationConfig config, Class<Enum<?>> enumCls0)
constructUsingIndex(DeserializationConfig, AnnotatedClass)
instead.@Deprecated public static EnumResolver constructUsingEnumNamingStrategy(DeserializationConfig config, Class<?> enumCls0, EnumNamingStrategy enumNamingStrategy)
constructUsingEnumNamingStrategy(DeserializationConfig, AnnotatedClass, EnumNamingStrategy)
.EnumNamingStrategy
.
The output EnumResolver
should contain values that are symmetric to
EnumValues.constructUsingEnumNamingStrategy(MapperConfig, Class, EnumNamingStrategy)
.public static EnumResolver constructUsingEnumNamingStrategy(DeserializationConfig config, AnnotatedClass annotatedClass, EnumNamingStrategy enumNamingStrategy)
EnumResolver
with EnumNamingStrategy
applied.@Deprecated public static EnumResolver constructUsingMethod(DeserializationConfig config, Class<?> enumCls0, AnnotatedMember accessor)
constructUsingMethod(DeserializationConfig, AnnotatedClass, AnnotatedMember)
instead.public static EnumResolver constructUsingMethod(DeserializationConfig config, AnnotatedClass annotatedClass, AnnotatedMember accessor)
public CompactStringObjectMap constructLookup()
protected static Enum<?> _enumDefault(AnnotationIntrospector intr, AnnotatedClass annotatedClass, Enum<?>[] enums)
AnnotationIntrospector.findDefaultEnumValue(AnnotatedClass, Enum[])
@Deprecated protected static Enum<?> _enumDefault(AnnotationIntrospector intr, Class<?> enumCls)
_enumDefault(AnnotationIntrospector, AnnotatedClass, Enum[])
instead.protected static boolean _isIntType(Class<?> erasedType)
public Enum<?> getEnum(int index)
public Enum<?> getDefaultValue()
public Enum<?>[] getRawEnums()
public Collection<String> getEnumIds()
public int lastValidIndex()
public boolean isFromIntValue()
@JsonValue
annotated accessor with integral type: this
matters for cases where incoming content value is of integral type
and should be mapped to specific value and NOT to Enum.index()
.Copyright © 2008–2023 FasterXML. All rights reserved.