- Type Parameters:
T-K-V-
- All Implemented Interfaces:
com.fasterxml.jackson.databind.deser.NullValueProvider,com.fasterxml.jackson.databind.deser.ValueInstantiator.Gettable,Serializable
- Direct Known Subclasses:
AuraDescDeserializer,CardCostModifierDescDeserializer,CardSourceDescDeserializer,ConditionDescDeserializer,DynamicDescriptionDeserializer,EntityFilterDescDeserializer,EventTriggerDescDeserializer,SpellDescDeserializer,ValueProviderDescDeserializer
Spell, has a corresponding Desc, like SpellDesc, which is
deserialized by this class's implementor SpellDescDeserializer. In that class, the
#init(SerializationContext) implementation adds the mappings from each enum value of SpellArg to its
corresponding ParseValueType.
To help visualize, this means that if <K> is your enum type and <V> is your class deserialize to,
you'll have:
- A type
<T>that is a "desc", which is a map of<K>to objects. - A
DescDeserializerthat readscamelCasedversions of<K>and applies them as keys to<T extends Map<K, Object>> - An entry in
ParseValueTypethat corresponds to<T>, deserialized byParseUtils.parse(JsonNode, ParseValueType, DeserializationContext).
For example, for a Spell subclass like DamageSpell, you might see
the JSON:
"spell": {
"class": "DamageSpell",
"value": {
"class": "CurrentTurnValueProvider"
},
"target": "ENEMY_CHARACTERS"
}
ParseUtils.parse(JsonNode, ParseValueType, DeserializationContext) knows to turn "spell" into a
SpellDesc instance because in some #init(SerializationContext), an arg (like SpellArg.SPELL)
is configured to be of type ParseValueType.SPELL.
Then, a field like "class" is known to be the "class arg" and is put with
SpellArg.CLASS as the key and a Class instance as a value. For a field like "value", it is
turned into UPPER_CASE (so "VALUE") and simply passed to Enum.valueOf(Class, String) to find
the corresponding enum constant to use as the key. The init implementation specifies that SpellArg.VALUE is a ParseValueType.VALUE, which is a union of types of integer or a ValueProviderDesc. If it encounters a number, it'll put a number into the desc map. Otherwise, it will
decode a ValueProviderDesc using a similar process and actually instantiate it into its concrete type using
Desc.create(). That means it will look up the "class" field as a class (in this case,
"CurrentTurnValueProvider") and create an instance of it. So all in all, the Java equivalent of deserializing the
JSON example above looks like:
SpellDesc desc = new SpellDesc(DamageSpell.class);
desc.put(SpellArg.TARGET, EntityReference.ENEMY_CHARACTERS);
ValueProviderDesc valueProviderDesc = new ValueProviderDesc(CurrentTurnValueProvider.class);
ValueProvider valueProvider = valueProviderDesc.create();
desc.put(SpellArg.VALUE, valueProvider);
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer
com.fasterxml.jackson.databind.JsonDeserializer.None -
Field Summary
Fields inherited from class com.fasterxml.jackson.databind.deser.std.StdDeserializer
_valueClass, _valueType, F_MASK_ACCEPT_ARRAYS, F_MASK_INT_COERCIONS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Tdeserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) abstract voidinit(DescDeserializer<T, K, V>.SerializationContext ctx) Gives the implementing deserializer the opportunity to specify how a key in its enum should be deserialized.innerDeserialize(com.fasterxml.jackson.databind.DeserializationContext ctxt, com.fasterxml.jackson.databind.JsonNode node) 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, _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, deserializeWithType, findContentNullProvider, findContentNullStyle, findConvertingContentDeserializer, findDeserializer, findFormatFeature, findFormatOverrides, findValueNullProvider, getValueClass, getValueInstantiator, getValueType, getValueType, handledType, handleMissingEndArrayForSingle, handleNestedArrayForSingle, handleUnknownProperty, isDefaultDeserializer, isDefaultKeyDeserializerMethods inherited from class com.fasterxml.jackson.databind.JsonDeserializer
deserialize, deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getEmptyAccessPattern, getEmptyValue, getEmptyValue, getKnownPropertyNames, getNullAccessPattern, getNullValue, getNullValue, getObjectIdReader, isCachable, logicalType, replaceDelegatee, supportsUpdate, unwrappingDeserializer
-
Constructor Details
-
DescDeserializer
-
-
Method Details
-
createDescInstance
-
init
Gives the implementing deserializer the opportunity to specify how a key in its enum should be deserialized.Call the
DescDeserializer.SerializationContext.add(Enum, ParseValueType)method to specify this mapping.- Parameters:
ctx- The serialization context.
-
getAbstractComponentClass
-
getEnumType
-
deserialize
public T deserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException - Specified by:
deserializein classcom.fasterxml.jackson.databind.JsonDeserializer<T extends Desc<K,V>> - Throws:
IOException
-
innerDeserialize
public T innerDeserialize(com.fasterxml.jackson.databind.DeserializationContext ctxt, com.fasterxml.jackson.databind.JsonNode node) throws com.fasterxml.jackson.databind.JsonMappingException - Throws:
com.fasterxml.jackson.databind.JsonMappingException
-