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
    Modifier and Type | Field and Description
    --- | ---
    `protected Enum<?>` | `_defaultValue`
    `protected Class<Enum<?>>` | `_enumClass`
    `protected Enum<?>[]` | `_enums`
    `protected HashMap<String,Enum<?>>` | `_enumsById`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `EnumResolver(Class<Enum<?>> enumClass, Enum<?>[] enums, HashMap<String,Enum<?>> map, Enum<?> defaultValue)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static EnumResolver` | `constructFor(Class<Enum<?>> enumCls, AnnotationIntrospector ai)` Factory method for constructing resolver that maps from Enum.name() into Enum value
    `CompactStringObjectMap` | `constructLookup()`
    `static EnumResolver` | `constructUnsafe(Class<?> rawEnumCls, AnnotationIntrospector ai)` This method is needed because of the dynamic nature of constructing Enum resolvers.
    `static EnumResolver` | `constructUnsafeUsingMethod(Class<?> rawEnumCls, AnnotatedMember accessor, AnnotationIntrospector ai)` Method used when actual String serialization is indicated using @JsonValue on a method.
    `static EnumResolver` | `constructUnsafeUsingToString(Class<?> rawEnumCls, AnnotationIntrospector ai)` Method that needs to be used instead of `constructUsingToString(java.lang.Class<java.lang.Enum<?>>)` if static type of enum is not known.
    `static EnumResolver` | `constructUsingMethod(Class<Enum<?>> enumCls, AnnotatedMember accessor, AnnotationIntrospector ai)`
    `static EnumResolver` | `constructUsingToString(Class<Enum<?>> enumCls)` Deprecated. Since 2.8, use `constructUsingToString(Class, AnnotationIntrospector)` instead
    `static EnumResolver` | `constructUsingToString(Class<Enum<?>> enumCls, AnnotationIntrospector ai)` 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()`
    `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

  - ### Constructor Detail

    - #### EnumResolver

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

  - ### Method Detail

    - #### constructFor

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

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

    - #### constructUsingToString

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

      Deprecated. Since 2.8, use `constructUsingToString(Class, AnnotationIntrospector)` instead

    - #### constructUsingToString

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

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

    - #### constructUsingMethod

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

      Since:
        2.9

    - #### constructUnsafe

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

      This method is needed because of the dynamic nature of constructing Enum resolvers.

    - #### constructUnsafeUsingToString

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

      Method that needs to be used instead of `constructUsingToString(java.lang.Class<java.lang.Enum<?>>)` if static type of enum is not known.
      Since:
        2.8

    - #### constructUnsafeUsingMethod

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

      Method used when actual String serialization is indicated using @JsonValue on a method.
      Since:
        2.9

    - #### constructLookup

          public CompactStringObjectMap constructLookup()

    - #### findEnum

          public Enum<?> findEnum(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()

Copyright © 2008–2020 FasterXML. All rights reserved.