Class BuilderBasedDeserializer

All Implemented Interfaces:
NullValueProvider, ValueInstantiator.Gettable

public class BuilderBasedDeserializer extends BeanDeserializerBase
Class that handles deserialization using a separate Builder class, which is used for data binding and produces actual deserialized value at the end of data binding.

Note on implementation: much of code has been copied from BeanDeserializer; there may be opportunities to refactor this in future.

  • Field Details

    • _buildMethod

      protected final AnnotatedMethod _buildMethod
    • _targetType

      protected final JavaType _targetType
      Type that the builder will produce, target type; as opposed to `handledType()` which refers to Builder class.
    • _propertyNameMatcher

      protected tools.jackson.core.sym.PropertyNameMatcher _propertyNameMatcher
    • _propertiesByIndex

      protected SettableBeanProperty[] _propertiesByIndex
  • Constructor Details

  • Method Details

    • initNameMatcher

      protected void initNameMatcher(DeserializationContext ctxt)
      Specified by:
      initNameMatcher in class BeanDeserializerBase
    • unwrappingDeserializer

      public ValueDeserializer<Object> unwrappingDeserializer(DeserializationContext ctxt, NameTransformer transformer)
      Description copied from class: ValueDeserializer
      Method that will return deserializer instance that is able to handle "unwrapped" value instances If no unwrapped instance can be constructed, will simply return this object as-is.

      Default implementation just returns 'this' indicating that no unwrapped variant exists

      Specified by:
      unwrappingDeserializer in class BeanDeserializerBase
    • withObjectIdReader

      public BeanDeserializerBase withObjectIdReader(ObjectIdReader oir)
      Specified by:
      withObjectIdReader in class BeanDeserializerBase
    • withByNameInclusion

      public BeanDeserializerBase withByNameInclusion(Set<String> ignorableProps, Set<String> includableProps)
      Specified by:
      withByNameInclusion in class BeanDeserializerBase
    • withIgnoreAllUnknown

      public BeanDeserializerBase withIgnoreAllUnknown(boolean ignoreUnknown)
      Specified by:
      withIgnoreAllUnknown in class BeanDeserializerBase
    • withBeanProperties

      public BeanDeserializerBase withBeanProperties(BeanPropertyMap props)
      Description copied from class: BeanDeserializerBase
      Mutant factory method that custom sub-classes must override; not left as abstract to prevent more drastic backwards compatibility problems.
      Overrides:
      withBeanProperties in class BeanDeserializerBase
    • asArrayDeserializer

      protected BeanDeserializerBase asArrayDeserializer()
      Description copied from class: BeanDeserializerBase
      Fluent factory for creating a variant that can handle POJO output as a JSON Array. Implementations may ignore this request if no such input is possible.
      Specified by:
      asArrayDeserializer in class BeanDeserializerBase
    • supportsUpdate

      public Boolean supportsUpdate(DeserializationConfig config)
      Description copied from class: ValueDeserializer
      Introspection method that may be called to see whether deserializer supports update of an existing value (aka "merging") or not. Return value should either be Boolean.FALSE if update is not supported at all (immutable values); Boolean.TRUE if update should usually work (regular POJOs, for example), or null if this is either not known, or may sometimes work.

      Information gathered is typically used to either prevent merging update for property (either by skipping, if based on global defaults; or by exception during deserializer construction if explicit attempt made) if Boolean.FALSE returned, or inclusion if Boolean.TRUE is specified. If "unknown" case (null returned) behavior is to exclude property if global defaults used; or to allow if explicit per-type or property merging is defined.

      Default implementation returns null to allow explicit per-type or per-property attempts.

      Overrides:
      supportsUpdate in class BeanDeserializerBase
    • finishBuild

      protected Object finishBuild(DeserializationContext ctxt, Object builder) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • deserialize

      public Object deserialize(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      Main deserialization method for bean-based objects (POJOs).
      Specified by:
      deserialize in class ValueDeserializer<Object>
      Parameters:
      p - Parser used for reading JSON content
      ctxt - Context that can be used to access information about this deserialization activity.
      Returns:
      Deserialized value
      Throws:
      tools.jackson.core.JacksonException
    • deserialize

      public Object deserialize(tools.jackson.core.JsonParser p, DeserializationContext ctxt, Object value) throws tools.jackson.core.JacksonException
      Secondary deserialization method, called in cases where POJO instance is created as part of deserialization, potentially after collecting some or all of the properties to set.
      Overrides:
      deserialize in class ValueDeserializer<Object>
      Throws:
      tools.jackson.core.JacksonException
    • deserializeFromObject

      public Object deserializeFromObject(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      General version used when handling needs more advanced features.
      Specified by:
      deserializeFromObject in class BeanDeserializerBase
      Throws:
      tools.jackson.core.JacksonException
    • _deserializeUsingPropertyBased

      protected Object _deserializeUsingPropertyBased(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      Method called to deserialize bean using "property-based creator": this means that a non-default constructor or factory method is called, and then possibly other setters. The trick is that values for creator method need to be buffered, first; and due to non-guaranteed ordering possibly some other properties as well.
      Specified by:
      _deserializeUsingPropertyBased in class BeanDeserializerBase
      Returns:
      Builder instance constructed
      Throws:
      tools.jackson.core.JacksonException
    • _deserialize

      protected final Object _deserialize(tools.jackson.core.JsonParser p, DeserializationContext ctxt, Object builder) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _deserializeFromArray

      protected Object _deserializeFromArray(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      Description copied from class: StdDeserializer
      Helper method that allows easy support for array-related coercion features: checks for either empty array, or single-value array-wrapped value (if coercion enabled by CoercionConfigs (since 2.12), and either reports an exception (if no coercion allowed), or returns appropriate result value using coercion mechanism indicated.

      This method should NOT be called if Array representation is explicitly supported for type: it should only be called in case it is otherwise unrecognized.

      NOTE: in case of unwrapped single element, will handle actual decoding by calling StdDeserializer._deserializeWrappedValue(tools.jackson.core.JsonParser, tools.jackson.databind.DeserializationContext), which by default calls ValueDeserializer.deserialize(JsonParser, DeserializationContext).

      Overrides:
      _deserializeFromArray in class StdDeserializer<Object>
      Throws:
      tools.jackson.core.JacksonException
    • deserializeWithView

      protected final Object deserializeWithView(tools.jackson.core.JsonParser p, DeserializationContext ctxt, Object bean, Class<?> activeView) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • deserializeWithUnwrapped

      protected Object deserializeWithUnwrapped(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      Method called when there are declared "unwrapped" properties which need special handling
      Throws:
      tools.jackson.core.JacksonException
    • deserializeWithUnwrapped

      protected Object deserializeWithUnwrapped(tools.jackson.core.JsonParser p, DeserializationContext ctxt, Object builder, TokenBuffer tokens) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • deserializeUsingPropertyBasedWithUnwrapped

      protected Object deserializeUsingPropertyBasedWithUnwrapped(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • deserializeWithExternalTypeId

      protected Object deserializeWithExternalTypeId(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • deserializeWithExternalTypeId

      protected Object deserializeWithExternalTypeId(tools.jackson.core.JsonParser p, DeserializationContext ctxt, Object bean) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • deserializeUsingPropertyBasedWithExternalTypeId

      protected Object deserializeUsingPropertyBasedWithExternalTypeId(tools.jackson.core.JsonParser p, DeserializationContext ctxt) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _handleUnexpectedWithin

      protected Object _handleUnexpectedWithin(tools.jackson.core.JsonParser p, DeserializationContext ctxt, Object beanOrBuilder) throws tools.jackson.core.JacksonException
      Method called if an unexpected token (other then FIELD_NAME) is found after POJO has been instantiated and partially bound.
      Throws:
      tools.jackson.core.JacksonException
      Since:
      3.0