com.fasterxml.jackson.databind.util

## Class EnumResolver

- java.lang.Object
- - com.fasterxml.jackson.databind.util.EnumResolver

All Implemented Interfaces:
  Serializable

    public class EnumResolver
    extends Object
    implements Serializable

Helper class used to resolve String values (either JSON Object field names or regular String values) into Java Enum instances.

See Also:
  Serialized Form

### Field Summary

Fields
`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

### Constructor Summary

Constructors
`protected` `EnumResolver(Class<Enum<?>> enumClass, Enum<?>[] enums, HashMap<String,Enum<?>> map, Enum<?> defaultValue, boolean isIgnoreCase, boolean isFromIntValue)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`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. Since 2.16. Use `constructUsingEnumNamingStrategy(DeserializationConfig, AnnotatedClass, EnumNamingStrategy)`.
`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()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### _enumClass

    protected final Class<Enum<?>> _enumClass

#### _enums

    protected final Enum<?>[] _enums

#### _enumsById

    protected final HashMap<String,Enum<?>> _enumsById

#### _defaultValue

    protected final Enum<?> _defaultValue

#### _isIgnoreCase

    protected final boolean _isIgnoreCase

Marker for case-insensitive handling

Since:
  2.12

#### _isFromIntValue

    protected final 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).

Special case is needed since this specifically means that `Enum.index()` should NOT be used or default to.

Since:
  2.13

### Constructor Detail

#### EnumResolver

    protected EnumResolver(Class<Enum<?>> enumClass,
                           Enum<?>[] enums,
                           HashMap<String,Enum<?>> map,
                           Enum<?> defaultValue,
                           boolean isIgnoreCase,
                           boolean isFromIntValue)

Since:
  2.12

### Method Detail

#### constructFor

    public 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.

Parameters:
  `config` - the deserialization configuration to use
  `annotatedClass` - the annotated class of the enum to be resolved
Returns:
  the constructed `EnumResolver`
Since:
  2.16

#### constructFor

    @Deprecated
    public static EnumResolver constructFor(DeserializationConfig config,
                                                        Class<?> enumCls0)

Deprecated. Since 2.16 use `constructFor(DeserializationConfig, AnnotatedClass)` instead
Factory method for constructing resolver that maps from Enum.name() into Enum value.

Since:
  2.12

#### constructUsingToString

    public static EnumResolver constructUsingToString(DeserializationConfig config,
                                                      AnnotatedClass annotatedClass)

Factory method for constructing resolver that maps from Enum.toString() into Enum value

Since:
  2.16

#### constructUsingToString

    @Deprecated
    public static EnumResolver constructUsingToString(DeserializationConfig config,
                                                                  Class<?> enumCls0)

Deprecated. Since 2.16 use `constructUsingToString(DeserializationConfig, AnnotatedClass)` instead
Factory method for constructing resolver that maps from Enum.toString() into Enum value

Since:
  2.12

#### constructUsingIndex

    public static EnumResolver constructUsingIndex(DeserializationConfig config,
                                                   AnnotatedClass annotatedClass)

Factory method for constructing resolver that maps from index of Enum.values() into Enum value.

Since:
  2.16

#### constructUsingIndex

    @Deprecated
    public static EnumResolver constructUsingIndex(DeserializationConfig config,
                                                               Class<Enum<?>> enumCls0)

Deprecated. Since 2.16. Use `constructUsingIndex(DeserializationConfig, AnnotatedClass)` instead.
Factory method for constructing resolver that maps from index of Enum.values() into Enum value

Since:
  2.15

#### constructUsingEnumNamingStrategy

    @Deprecated
    public static EnumResolver constructUsingEnumNamingStrategy(DeserializationConfig config,
                                                                            Class<?> enumCls0,
                                                                            EnumNamingStrategy enumNamingStrategy)

Deprecated. Since 2.16. Use `constructUsingEnumNamingStrategy(DeserializationConfig, AnnotatedClass, EnumNamingStrategy)`.
Factory method for constructing resolver that maps the name of enums converted to external property names into Enum value using an implementation of `EnumNamingStrategy`. The output `EnumResolver` should contain values that are symmetric to `EnumValues.constructUsingEnumNamingStrategy(MapperConfig, Class, EnumNamingStrategy)`.

Since:
  2.15

#### constructUsingEnumNamingStrategy

    public static EnumResolver constructUsingEnumNamingStrategy(DeserializationConfig config,
                                                                AnnotatedClass annotatedClass,
                                                                EnumNamingStrategy enumNamingStrategy)

Factory method for constructing an `EnumResolver` with `EnumNamingStrategy` applied.

Since:
  2.16

#### constructUsingMethod

    @Deprecated
    public static EnumResolver constructUsingMethod(DeserializationConfig config,
                                                                Class<?> enumCls0,
                                                                AnnotatedMember accessor)

Deprecated. Since 2.16. Use `constructUsingMethod(DeserializationConfig, AnnotatedClass, AnnotatedMember)` instead.
Method used when actual String serialization is indicated using @JsonValue on a method in Enum class.

Since:
  2.12

#### constructUsingMethod

    public 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.

Since:
  2.16

#### constructLookup

    public CompactStringObjectMap constructLookup()

#### _enumClass

    protected static Class<Enum<?>> _enumClass(Class<?> enumCls0)

#### _enumConstants

    protected static Enum<?>[] _enumConstants(Class<?> enumCls)

#### _enumDefault

    protected static Enum<?> _enumDefault(AnnotationIntrospector intr,
                                          AnnotatedClass annotatedClass,
                                          Enum<?>[] enums)

Internal helper method used to resolve Enum default value to use (if any).

Since:
  2.16
See Also:
  `AnnotationIntrospector.findDefaultEnumValue(AnnotatedClass, Enum[])`

#### _enumDefault

    @Deprecated
    protected static Enum<?> _enumDefault(AnnotationIntrospector intr,
                                                      Class<?> enumCls)

Deprecated. Since 2.16. Use `_enumDefault(AnnotationIntrospector, AnnotatedClass, Enum[])` instead.

#### _isIntType

    protected static boolean _isIntType(Class<?> erasedType)

#### findEnum

    public Enum<?> findEnum(String key)

#### _findEnumCaseInsensitive

    protected Enum<?> _findEnumCaseInsensitive(String key)

#### getEnum

    public Enum<?> getEnum(int index)

#### getDefaultValue

    public Enum<?> getDefaultValue()

#### getRawEnums

    public Enum<?>[] getRawEnums()

#### getEnums

    public List<Enum<?>> getEnums()

#### getEnumIds

    public Collection<String> getEnumIds()

Since:
  2.7.3

#### getEnumClass

    public Class<Enum<?>> getEnumClass()

#### lastValidIndex

    public int lastValidIndex()

#### isFromIntValue

    public 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()`.

Since:
  2.13