Package de.aristaflow.ilm.util.jackson
Class DistFieldDeserialiser<F,F1 extends F,F2 extends F>
java.lang.Object
com.fasterxml.jackson.databind.JsonDeserializer<F>
de.aristaflow.ilm.util.jackson.DistFieldDeserialiser<F,F1,F2>
- Type Parameters:
F- The deserialised type.F1- The more specific deserialised type in case the distinguishing field is not present.F2- The more specific deserialised type in case the distinguishing field is present.
- All Implemented Interfaces:
com.fasterxml.jackson.databind.deser.NullValueProvider
public abstract class DistFieldDeserialiser<F,F1 extends F,F2 extends F>
extends com.fasterxml.jackson.databind.JsonDeserializer<F>
This deserialiser chooses between two different class hierarchy based on the presence of a
specific field (name).
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer
com.fasterxml.jackson.databind.JsonDeserializer.None -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringThe name of the field which distinguishes between deserialising either class hierarchy.The class of which to retrieve (sub-)instances of by using Jackson deserialisation ifdistFieldNameis not present.The filter class of which to retrieve (sub-)instances of by using Jackson deserialisation ifdistFieldNameis present. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchooseSubtypeHierarchy(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) Determines whether the designated stream has a field (at the current object) with thedistFieldNameby returning whether the field has been found.deserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) deserializeWithType(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt, com.fasterxml.jackson.databind.jsontype.TypeDeserializer typeDeserializer) Methods inherited from class com.fasterxml.jackson.databind.JsonDeserializer
deserialize, deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getEmptyAccessPattern, getEmptyValue, getEmptyValue, getKnownPropertyNames, getNullAccessPattern, getNullValue, getNullValue, getObjectIdReader, handledType, isCachable, logicalType, replaceDelegatee, supportsUpdate, unwrappingDeserializer
-
Field Details
-
root1
The class of which to retrieve (sub-)instances of by using Jackson deserialisation ifdistFieldNameis not present. -
distFieldName
The name of the field which distinguishes between deserialising either class hierarchy. -
root2
The filter class of which to retrieve (sub-)instances of by using Jackson deserialisation ifdistFieldNameis present.
-
-
Constructor Details
-
DistFieldDeserialiser
Creates a new deserialiser for different class hierarchies distinguished via the presence of the designated field. If the designated field is present, instances ofroot2will be deserialised, otherwise instances ofroot1will be deserialised.- Parameters:
root1- The filter class of which to retrieve (sub-)instances of by using Jackson deserialisation ifdistFieldNameis not present.distFieldName- The name of the field which distinguishes between deserialising either class hierarchy.root2- The filter class of which to retrieve (sub-)instances of by using Jackson deserialisation ifdistFieldNameis present.
-
-
Method Details
-
chooseSubtypeHierarchy
protected Pair<Boolean,com.fasterxml.jackson.core.JsonParser> chooseSubtypeHierarchy(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException Determines whether the designated stream has a field (at the current object) with thedistFieldNameby returning whether the field has been found.- Parameters:
p- The parser providing the JSON.ctxt- The context in which to deserialise from the designated JSON (parser).- Returns:
- Whether the
distFieldNamehas been found or not and the designated JSON parser wrapped and positioned at the position when calling this method. - Throws:
IOException- If there are problems reading from the designated JSON (parser), anIOExceptionwill be thrown.
-
deserialize
public F deserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException - Specified by:
deserializein classcom.fasterxml.jackson.databind.JsonDeserializer<F>- Throws:
IOException
-
deserializeWithType
public Object deserializeWithType(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt, com.fasterxml.jackson.databind.jsontype.TypeDeserializer typeDeserializer) throws IOException - Overrides:
deserializeWithTypein classcom.fasterxml.jackson.databind.JsonDeserializer<F>- Throws:
IOException
-