Class EnumDeserializer

java.lang.Object
com.fasterxml.jackson.databind.JsonDeserializer<T>
com.fasterxml.jackson.databind.deser.std.StdDeserializer<T>
com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer<Object>
com.fasterxml.jackson.databind.deser.std.EnumDeserializer
All Implemented Interfaces:
com.fasterxml.jackson.databind.deser.ContextualDeserializer, com.fasterxml.jackson.databind.deser.NullValueProvider, com.fasterxml.jackson.databind.deser.ValueInstantiator.Gettable, Serializable

@Deprecated public class EnumDeserializer extends com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer<Object> implements com.fasterxml.jackson.databind.deser.ContextualDeserializer
Deprecated.
枚举类反序列化程序类,可以从字符串和整数反序列化指定枚举类的实例。 官方提供的,支持(但不限于)以下接收方式: 1、字符串 如:sex: "M" 2、数字 如:sex: 1 // 数字需要和枚举类的顺序对应,超过会报错。 如Sex 有M、W、N ,则数字只能是 0、1、2 3、数组 还不清楚怎么使用...

我重写了后,增强了以下功能。 1、传递的枚举类型可以是对象. 如: sex: { "code": "M" }

本类跟jackson-databind包中的EnumDeserializer类同包名,利用类加载机制,会加载此类,不会加载到jackson-databind中的类 参考 BasicDeserializerFactory#1495 行代码

Version:
3.2.1
Author:
zuihou
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer

    com.fasterxml.jackson.databind.JsonDeserializer.None
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Boolean
    Deprecated.
     
    protected Object[]
    Deprecated.
     
    protected final boolean
    Deprecated.
     
    protected final com.fasterxml.jackson.databind.util.CompactStringObjectMap
    Deprecated.
     
    protected final com.fasterxml.jackson.databind.util.CompactStringObjectMap
    Deprecated.
     
    protected com.fasterxml.jackson.databind.util.CompactStringObjectMap
    Deprecated.
     

    Fields inherited from class com.fasterxml.jackson.databind.deser.std.StdDeserializer

    _valueClass, _valueType, F_MASK_ACCEPT_ARRAYS, F_MASK_INT_COERCIONS
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    EnumDeserializer(EnumDeserializer base, Boolean caseInsensitive)
    Deprecated. 
    protected
    EnumDeserializer(EnumDeserializer base, Boolean caseInsensitive, Boolean useDefaultValueForUnknownEnum, Boolean useNullForUnknownEnum)
    Deprecated.
     
     
    EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver)
    Deprecated. 
     
    EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver, boolean caseInsensitive, com.fasterxml.jackson.databind.util.EnumResolver byEnumNamingResolver)
    Deprecated. 
     
    EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver, boolean caseInsensitive, com.fasterxml.jackson.databind.util.EnumResolver byEnumNamingResolver, com.fasterxml.jackson.databind.util.EnumResolver toStringResolver)
    Deprecated.
     
     
    EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver, Boolean caseInsensitive)
    Deprecated. 
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Object
    _deserializeOther(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt)
    Deprecated.
     
    protected Class<?>
    Deprecated.
     
    protected Object
    _fromInteger(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt, int index)
    Deprecated.
     
    protected Object
    _fromString(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt, String text)
    Deprecated.
     
    protected com.fasterxml.jackson.databind.util.CompactStringObjectMap
    _getToStringLookup(com.fasterxml.jackson.databind.DeserializationContext ctxt)
    Deprecated. 
    com.fasterxml.jackson.databind.JsonDeserializer<?>
    createContextual(com.fasterxml.jackson.databind.DeserializationContext ctxt, com.fasterxml.jackson.databind.BeanProperty property)
    Deprecated.
     
    deserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt)
    Deprecated.
     
    static com.fasterxml.jackson.databind.JsonDeserializer<?>
    deserializerForCreator(com.fasterxml.jackson.databind.DeserializationConfig config, Class<?> enumClass, com.fasterxml.jackson.databind.introspect.AnnotatedMethod factory)
    Deprecated. 
    static com.fasterxml.jackson.databind.JsonDeserializer<?>
    deserializerForCreator(com.fasterxml.jackson.databind.DeserializationConfig config, Class<?> enumClass, com.fasterxml.jackson.databind.introspect.AnnotatedMethod factory, com.fasterxml.jackson.databind.deser.ValueInstantiator valueInstantiator, com.fasterxml.jackson.databind.deser.SettableBeanProperty[] creatorProps)
    Deprecated.
     
    static com.fasterxml.jackson.databind.JsonDeserializer<?>
    deserializerForNoArgsCreator(com.fasterxml.jackson.databind.DeserializationConfig config, Class<?> enumClass, com.fasterxml.jackson.databind.introspect.AnnotatedMethod factory)
    Deprecated.
     
    getEmptyValue(com.fasterxml.jackson.databind.DeserializationContext ctxt)
    Deprecated.
     
    boolean
    Deprecated.
     
    com.fasterxml.jackson.databind.type.LogicalType
    Deprecated.
     
    protected boolean
    useDefaultValueForUnknownEnum(com.fasterxml.jackson.databind.DeserializationContext ctxt)
    Deprecated.
     
    protected boolean
    useNullForUnknownEnum(com.fasterxml.jackson.databind.DeserializationContext ctxt)
    Deprecated.
     
    withResolved(Boolean caseInsensitive)
    Deprecated. 
    withResolved(Boolean caseInsensitive, Boolean useDefaultValueForUnknownEnum, Boolean useNullForUnknownEnum)
    Deprecated.
     

    Methods inherited from class com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer

    deserialize, deserializeWithType, getEmptyAccessPattern, getNullAccessPattern, supportsUpdate

    Methods inherited from class com.fasterxml.jackson.databind.deser.std.StdDeserializer

    _byteOverflow, _checkBooleanToStringCoercion, _checkCoercionFail, _checkDoubleSpecialValue, _checkFloatSpecialValue, _checkFloatToIntCoercion, _checkFloatToStringCoercion, _checkFromStringCoercion, _checkFromStringCoercion, _checkIntToFloatCoercion, _checkIntToStringCoercion, _checkTextualNull, _checkToStringCoercion, _coerceBooleanFromInt, _coercedTypeDesc, _coercedTypeDesc, _coerceEmptyString, _coerceIntegral, _coerceNullToken, _coerceTextualNull, _deserializeFromArray, _deserializeFromEmpty, _deserializeFromEmptyString, _deserializeFromString, _deserializeWrappedValue, _failDoubleToIntCoercion, _findCoercionFromBlankString, _findCoercionFromEmptyArray, _findCoercionFromEmptyString, _findNullProvider, _hasTextualNull, _intOverflow, _isBlank, _isEmptyOrTextualNull, _isFalse, _isIntNumber, _isNaN, _isNegInf, _isPosInf, _isTrue, _neitherNull, _nonNullNumber, _parseBoolean, _parseBooleanFromInt, _parseBooleanPrimitive, _parseBooleanPrimitive, _parseBytePrimitive, _parseDate, _parseDate, _parseDateFromArray, _parseDouble, _parseDouble, _parseDoublePrimitive, _parseDoublePrimitive, _parseDoublePrimitive, _parseFloatPrimitive, _parseFloatPrimitive, _parseFloatPrimitive, _parseInteger, _parseInteger, _parseIntPrimitive, _parseIntPrimitive, _parseLong, _parseLong, _parseLongPrimitive, _parseLongPrimitive, _parseShortPrimitive, _parseString, _parseString, _reportFailedNullCoerce, _shortOverflow, _verifyEndArrayForSingle, _verifyNullForPrimitive, _verifyNullForPrimitiveCoercion, _verifyNullForScalarCoercion, _verifyNumberForScalarCoercion, _verifyStringForScalarCoercion, findContentNullProvider, findContentNullStyle, findConvertingContentDeserializer, findDeserializer, findFormatFeature, findFormatOverrides, findValueNullProvider, getValueClass, getValueInstantiator, getValueType, getValueType, handledType, handleMissingEndArrayForSingle, handleNestedArrayForSingle, handleUnknownProperty, isDefaultDeserializer, isDefaultKeyDeserializer

    Methods inherited from class com.fasterxml.jackson.databind.JsonDeserializer

    deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getEmptyValue, getKnownPropertyNames, getNullValue, getNullValue, getObjectIdReader, replaceDelegatee, unwrappingDeserializer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _lookupByName

      protected final com.fasterxml.jackson.databind.util.CompactStringObjectMap _lookupByName
      Deprecated.
    • _caseInsensitive

      protected final Boolean _caseInsensitive
      Deprecated.
    • _isFromIntValue

      protected final boolean _isFromIntValue
      Deprecated.
    • _lookupByEnumNaming

      protected final com.fasterxml.jackson.databind.util.CompactStringObjectMap _lookupByEnumNaming
      Deprecated.
    • _enumsByIndex

      protected Object[] _enumsByIndex
      Deprecated.
    • _lookupByToString

      protected volatile com.fasterxml.jackson.databind.util.CompactStringObjectMap _lookupByToString
      Deprecated.
  • Constructor Details

    • EnumDeserializer

      @Deprecated public EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver, Boolean caseInsensitive)
      Deprecated.
    • EnumDeserializer

      @Deprecated public EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver, boolean caseInsensitive, com.fasterxml.jackson.databind.util.EnumResolver byEnumNamingResolver)
      Deprecated.
    • EnumDeserializer

      public EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver, boolean caseInsensitive, com.fasterxml.jackson.databind.util.EnumResolver byEnumNamingResolver, com.fasterxml.jackson.databind.util.EnumResolver toStringResolver)
      Deprecated.
    • EnumDeserializer

      protected EnumDeserializer(EnumDeserializer base, Boolean caseInsensitive, Boolean useDefaultValueForUnknownEnum, Boolean useNullForUnknownEnum)
      Deprecated.
    • EnumDeserializer

      @Deprecated protected EnumDeserializer(EnumDeserializer base, Boolean caseInsensitive)
      Deprecated.
    • EnumDeserializer

      @Deprecated public EnumDeserializer(com.fasterxml.jackson.databind.util.EnumResolver byNameResolver)
      Deprecated.
  • Method Details

    • deserializerForCreator

      @Deprecated public static com.fasterxml.jackson.databind.JsonDeserializer<?> deserializerForCreator(com.fasterxml.jackson.databind.DeserializationConfig config, Class<?> enumClass, com.fasterxml.jackson.databind.introspect.AnnotatedMethod factory)
      Deprecated.
    • deserializerForCreator

      public static com.fasterxml.jackson.databind.JsonDeserializer<?> deserializerForCreator(com.fasterxml.jackson.databind.DeserializationConfig config, Class<?> enumClass, com.fasterxml.jackson.databind.introspect.AnnotatedMethod factory, com.fasterxml.jackson.databind.deser.ValueInstantiator valueInstantiator, com.fasterxml.jackson.databind.deser.SettableBeanProperty[] creatorProps)
      Deprecated.
    • deserializerForNoArgsCreator

      public static com.fasterxml.jackson.databind.JsonDeserializer<?> deserializerForNoArgsCreator(com.fasterxml.jackson.databind.DeserializationConfig config, Class<?> enumClass, com.fasterxml.jackson.databind.introspect.AnnotatedMethod factory)
      Deprecated.
    • withResolved

      public EnumDeserializer withResolved(Boolean caseInsensitive, Boolean useDefaultValueForUnknownEnum, Boolean useNullForUnknownEnum)
      Deprecated.
    • withResolved

      @Deprecated public EnumDeserializer withResolved(Boolean caseInsensitive)
      Deprecated.
    • createContextual

      public com.fasterxml.jackson.databind.JsonDeserializer<?> createContextual(com.fasterxml.jackson.databind.DeserializationContext ctxt, com.fasterxml.jackson.databind.BeanProperty property) throws com.fasterxml.jackson.databind.JsonMappingException
      Deprecated.
      Specified by:
      createContextual in interface com.fasterxml.jackson.databind.deser.ContextualDeserializer
      Throws:
      com.fasterxml.jackson.databind.JsonMappingException
    • isCachable

      public boolean isCachable()
      Deprecated.
      Overrides:
      isCachable in class com.fasterxml.jackson.databind.JsonDeserializer<Object>
    • logicalType

      public com.fasterxml.jackson.databind.type.LogicalType logicalType()
      Deprecated.
      Overrides:
      logicalType in class com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer<Object>
    • getEmptyValue

      public Object getEmptyValue(com.fasterxml.jackson.databind.DeserializationContext ctxt) throws com.fasterxml.jackson.databind.JsonMappingException
      Deprecated.
      Overrides:
      getEmptyValue in class com.fasterxml.jackson.databind.JsonDeserializer<Object>
      Throws:
      com.fasterxml.jackson.databind.JsonMappingException
    • deserialize

      public Object deserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException
      Deprecated.
      Specified by:
      deserialize in class com.fasterxml.jackson.databind.JsonDeserializer<Object>
      Throws:
      IOException
    • _fromString

      protected Object _fromString(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt, String text) throws IOException
      Deprecated.
      Throws:
      IOException
    • _fromInteger

      protected Object _fromInteger(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt, int index) throws IOException
      Deprecated.
      Throws:
      IOException
    • _deserializeOther

      protected Object _deserializeOther(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException
      Deprecated.
      Throws:
      IOException
    • _enumClass

      protected Class<?> _enumClass()
      Deprecated.
    • _getToStringLookup

      @Deprecated protected com.fasterxml.jackson.databind.util.CompactStringObjectMap _getToStringLookup(com.fasterxml.jackson.databind.DeserializationContext ctxt)
      Deprecated.
    • useNullForUnknownEnum

      protected boolean useNullForUnknownEnum(com.fasterxml.jackson.databind.DeserializationContext ctxt)
      Deprecated.
    • useDefaultValueForUnknownEnum

      protected boolean useDefaultValueForUnknownEnum(com.fasterxml.jackson.databind.DeserializationContext ctxt)
      Deprecated.