com.fasterxml.jackson.databind.util
Class EnumResolver<T extends Enum<T>>

java.lang.Object
  extended by com.fasterxml.jackson.databind.util.EnumResolver<T>

public class EnumResolver<T extends Enum<T>>
extends Object

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


Field Summary
protected  Class<T> _enumClass
           
protected  T[] _enums
           
protected  HashMap<String,T> _enumsById
           
 
Constructor Summary
protected EnumResolver(Class<T> enumClass, T[] enums, HashMap<String,T> map)
           
 
Method Summary
static
<ET extends Enum<ET>>
EnumResolver<ET>
constructFor(Class<ET> enumCls, AnnotationIntrospector ai)
          Factory method for constructing resolver that maps from Enum.name() into Enum value
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, Method accessor)
          Method used when actual String serialization is indicated using @JsonValue on a method.
static EnumResolver<?> constructUnsafeUsingToString(Class<?> rawEnumCls)
          Method that needs to be used instead of constructUsingToString(java.lang.Class) if static type of enum is not known.
static
<ET extends Enum<ET>>
EnumResolver<ET>
constructUsingMethod(Class<ET> enumCls, Method accessor)
           
static
<ET extends Enum<ET>>
EnumResolver<ET>
constructUsingToString(Class<ET> enumCls)
          Factory method for constructing resolver that maps from Enum.toString() into Enum value
 T findEnum(String key)
           
 T getEnum(int index)
           
 Class<T> getEnumClass()
           
 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<T extends Enum<T>> _enumClass

_enums

protected final T extends Enum<T>[] _enums

_enumsById

protected final HashMap<String,T extends Enum<T>> _enumsById
Constructor Detail

EnumResolver

protected EnumResolver(Class<T> enumClass,
                       T[] enums,
                       HashMap<String,T> map)
Method Detail

constructFor

public static <ET extends Enum<ET>> EnumResolver<ET> constructFor(Class<ET> enumCls,
                                                                  AnnotationIntrospector ai)
Factory method for constructing resolver that maps from Enum.name() into Enum value


constructUsingToString

public static <ET extends Enum<ET>> EnumResolver<ET> constructUsingToString(Class<ET> enumCls)
Factory method for constructing resolver that maps from Enum.toString() into Enum value


constructUsingMethod

public static <ET extends Enum<ET>> EnumResolver<ET> constructUsingMethod(Class<ET> enumCls,
                                                                          Method accessor)

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)
Method that needs to be used instead of constructUsingToString(java.lang.Class) if static type of enum is not known.


constructUnsafeUsingMethod

public static EnumResolver<?> constructUnsafeUsingMethod(Class<?> rawEnumCls,
                                                         Method accessor)
Method used when actual String serialization is indicated using @JsonValue on a method.


findEnum

public T findEnum(String key)

getEnum

public T getEnum(int index)

getEnumClass

public Class<T> getEnumClass()

lastValidIndex

public int lastValidIndex()


Copyright © 2012 fasterxml.com. All Rights Reserved.