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)` Deprecated. Since 2.12 (remove from 2.13+ not part of public API)
`protected` `EnumResolver(Class<Enum<?>> enumClass, Enum<?>[] enums, HashMap<String,Enum<?>> map, Enum<?> defaultValue, boolean isIgnoreCase)` Deprecated. Since 2.13
`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 EnumResolver` `_constructFor(Class<?> enumCls0, AnnotationIntrospector ai, boolean isIgnoreCase)`
`protected static EnumResolver` `_constructUsingMethod(Class<?> enumCls0, AnnotatedMember accessor, AnnotationIntrospector ai, boolean isIgnoreCase)`
`protected static EnumResolver` `_constructUsingToString(Class<?> enumCls0, AnnotationIntrospector ai, boolean isIgnoreCase)`
`protected static Class<Enum<?>>` `_enumClass(Class<?> enumCls0)`
`protected static Enum<?>[]` `_enumConstants(Class<?> enumCls)`
`protected static Enum<?>` `_enumDefault(AnnotationIntrospector intr, Class<?> enumCls)`
`protected Enum<?>` `_findEnumCaseInsensitive(String key)`
`protected static boolean` `_isIntType(Class<?> erasedType)`
`static EnumResolver` `constructFor(Class<Enum<?>> enumCls, AnnotationIntrospector ai)` Deprecated. Since 2.12
`static EnumResolver` `constructFor(DeserializationConfig config, Class<?> enumCls)` Factory method for constructing resolver that maps from Enum.name() into Enum value.
`CompactStringObjectMap` `constructLookup()`
`static EnumResolver` `constructUnsafe(Class<?> rawEnumCls, AnnotationIntrospector ai)` Deprecated. Since 2.12
`static EnumResolver` `constructUnsafeUsingMethod(Class<?> rawEnumCls, AnnotatedMember accessor, AnnotationIntrospector ai)` Deprecated. Since 2.12
`static EnumResolver` `constructUnsafeUsingToString(Class<?> rawEnumCls, AnnotationIntrospector ai)` Deprecated. Since 2.12
`static EnumResolver` `constructUsingMethod(Class<Enum<?>> enumCls, AnnotatedMember accessor, AnnotationIntrospector ai)` Deprecated. Since 2.12
`static EnumResolver` `constructUsingMethod(DeserializationConfig config, Class<?> enumCls, AnnotatedMember accessor)` Method used when actual String serialization is indicated using @JsonValue on a method in Enum class.
`static EnumResolver` `constructUsingToString(Class<Enum<?>> enumCls)` Deprecated. Since 2.8 (remove from 2.13 or later)
`static EnumResolver` `constructUsingToString(Class<Enum<?>> enumCls, AnnotationIntrospector ai)` Deprecated. Since 2.12
`static EnumResolver` `constructUsingToString(DeserializationConfig config, Class<?> enumCls)` Factory method for constructing resolver that maps from Enum.toString() into Enum value
`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

#### EnumResolver

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

Deprecated. Since 2.13

#### EnumResolver

    @Deprecated
    protected EnumResolver(Class<Enum<?>> enumClass,
                                       Enum<?>[] enums,
                                       HashMap<String,Enum<?>> map,
                                       Enum<?> defaultValue)

Deprecated. Since 2.12 (remove from 2.13+ not part of public API)

### Method Detail

#### constructFor

    public static EnumResolver constructFor(DeserializationConfig config,
                                            Class<?> enumCls)

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

Since:
  2.12

#### _constructFor

    protected static EnumResolver _constructFor(Class<?> enumCls0,
                                                AnnotationIntrospector ai,
                                                boolean isIgnoreCase)

Since:
  2.12

#### constructUsingToString

    public static EnumResolver constructUsingToString(DeserializationConfig config,
                                                      Class<?> enumCls)

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

Since:
  2.12

#### _constructUsingToString

    protected static EnumResolver _constructUsingToString(Class<?> enumCls0,
                                                          AnnotationIntrospector ai,
                                                          boolean isIgnoreCase)

Since:
  2.12

#### constructUsingMethod

    public static EnumResolver constructUsingMethod(DeserializationConfig config,
                                                    Class<?> enumCls,
                                                    AnnotatedMember accessor)

Method used when actual String serialization is indicated using @JsonValue on a method in Enum class.

Since:
  2.12

#### _constructUsingMethod

    protected static EnumResolver _constructUsingMethod(Class<?> enumCls0,
                                                        AnnotatedMember accessor,
                                                        AnnotationIntrospector ai,
                                                        boolean isIgnoreCase)

Since:
  2.12

#### 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,
                                          Class<?> enumCls)

#### _isIntType

    protected static boolean _isIntType(Class<?> erasedType)

#### constructFor

    @Deprecated
    public static EnumResolver constructFor(Class<Enum<?>> enumCls,
                                                        AnnotationIntrospector ai)

Deprecated. Since 2.12

#### constructUnsafe

    @Deprecated
    public static EnumResolver constructUnsafe(Class<?> rawEnumCls,
                                                           AnnotationIntrospector ai)

Deprecated. Since 2.12

#### constructUsingToString

    @Deprecated
    public static EnumResolver constructUsingToString(Class<Enum<?>> enumCls,
                                                                  AnnotationIntrospector ai)

Deprecated. Since 2.12

#### constructUnsafeUsingToString

    @Deprecated
    public static EnumResolver constructUnsafeUsingToString(Class<?> rawEnumCls,
                                                                        AnnotationIntrospector ai)

Deprecated. Since 2.12

Since:
  2.8

#### constructUsingToString

    @Deprecated
    public static EnumResolver constructUsingToString(Class<Enum<?>> enumCls)

Deprecated. Since 2.8 (remove from 2.13 or later)

#### constructUsingMethod

    @Deprecated
    public static EnumResolver constructUsingMethod(Class<Enum<?>> enumCls,
                                                                AnnotatedMember accessor,
                                                                AnnotationIntrospector ai)

Deprecated. Since 2.12

#### constructUnsafeUsingMethod

    @Deprecated
    public static EnumResolver constructUnsafeUsingMethod(Class<?> rawEnumCls,
                                                                      AnnotatedMember accessor,
                                                                      AnnotationIntrospector ai)

Deprecated. Since 2.12

Since:
  2.9

#### 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