Class DistFieldDeserialiser<F,​F1 extends F,​F2 extends F>

  • 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

      Fields 
      Modifier and Type Field Description
      protected String distFieldName
      The name of the field which distinguishes between deserialising either class hierarchy.
      protected Class<F1> root1
      The class of which to retrieve (sub-)instances of by using Jackson deserialisation if distFieldName is not present.
      protected Class<F2> root2
      The filter class of which to retrieve (sub-)instances of by using Jackson deserialisation if distFieldName is present.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected DistFieldDeserialiser​(Class<F1> root1, String distFieldName, Class<F2> root2)
      Creates a new deserialiser for different class hierarchies distinguished via the presence of the designated field.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Pair<Boolean,​com.fasterxml.jackson.core.JsonParser> chooseSubtypeHierarchy​(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 the distFieldName by returning whether the field has been found.
      F deserialize​(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt)  
      Object 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 Detail

      • root1

        protected final Class<F1 extends F> root1
        The class of which to retrieve (sub-)instances of by using Jackson deserialisation if distFieldName is not present.
      • distFieldName

        protected final String distFieldName
        The name of the field which distinguishes between deserialising either class hierarchy.
      • root2

        protected final Class<F2 extends F> root2
        The filter class of which to retrieve (sub-)instances of by using Jackson deserialisation if distFieldName is present.
    • Constructor Detail

      • DistFieldDeserialiser

        protected DistFieldDeserialiser​(Class<F1> root1,
                                        String distFieldName,
                                        Class<F2> root2)
        Creates a new deserialiser for different class hierarchies distinguished via the presence of the designated field. If the designated field is present, instances of root2 will be deserialised, otherwise instances of root1 will be deserialised.
        Parameters:
        root1 - The filter class of which to retrieve (sub-)instances of by using Jackson deserialisation if distFieldName is 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 if distFieldName is present.
    • Method Detail

      • 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 the distFieldName by 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 distFieldName has 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), an IOException will be thrown.
      • deserialize

        public F deserialize​(com.fasterxml.jackson.core.JsonParser p,
                             com.fasterxml.jackson.databind.DeserializationContext ctxt)
                      throws IOException
        Specified by:
        deserialize in class com.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:
        deserializeWithType in class com.fasterxml.jackson.databind.JsonDeserializer<F>
        Throws:
        IOException