com.fasterxml.jackson.databind.deser.impl

## Class ExternalTypeHandler

- java.lang.Object
- - com.fasterxml.jackson.databind.deser.impl.ExternalTypeHandler

-     public class ExternalTypeHandler
      extends Object

  Helper class that is used to flatten JSON structure when using "external type id" (see `JsonTypeInfo.As.EXTERNAL_PROPERTY`). This is needed to store temporary state and buffer tokens, as the structure is rearranged a bit so that actual type deserializer can resolve type and finalize deserialization.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ExternalTypeHandler.Builder`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ExternalTypeHandler(ExternalTypeHandler h)`
    `protected` | `ExternalTypeHandler(JavaType beanType, com.fasterxml.jackson.databind.deser.impl.ExternalTypeHandler.ExtTypedProperty[] properties, Map<String,Object> nameToPropertyIndex, String[] typeIds, TokenBuffer[] tokens)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `_deserialize(JsonParser p, DeserializationContext ctxt, int index, String typeId)`
    `protected void` | `_deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object bean, int index, String typeId)`
    `static ExternalTypeHandler.Builder` | `builder(JavaType beanType)`
    `Object` | `complete(JsonParser p, DeserializationContext ctxt, Object bean)` Method called after JSON Object closes, and has to ensure that all external type ids have been handled.
    `Object` | `complete(JsonParser p, DeserializationContext ctxt, PropertyValueBuffer buffer, PropertyBasedCreator creator)` Variant called when creation of the POJO involves buffering of creator properties as well as property-based creator.
    `boolean` | `handlePropertyValue(JsonParser p, DeserializationContext ctxt, String propName, Object bean)` Method called to ask handler to handle value of given property, at point where parser points to the first token of the value.
    `boolean` | `handleTypePropertyValue(JsonParser p, DeserializationContext ctxt, String propName, Object bean)` Method called to see if given property/value pair is an external type id; and if so handle it.
    `ExternalTypeHandler` | `start()` Method called to start collection process by creating non-blueprint instances.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExternalTypeHandler

          protected ExternalTypeHandler(JavaType beanType,
                                        com.fasterxml.jackson.databind.deser.impl.ExternalTypeHandler.ExtTypedProperty[] properties,
                                        Map<String,Object> nameToPropertyIndex,
                                        String[] typeIds,
                                        TokenBuffer[] tokens)

    - #### ExternalTypeHandler

          protected ExternalTypeHandler(ExternalTypeHandler h)

  - ### Method Detail

    - #### builder

          public static ExternalTypeHandler.Builder builder(JavaType beanType)

      Since:
        2.9

    - #### start

          public ExternalTypeHandler start()

      Method called to start collection process by creating non-blueprint instances.

    - #### handleTypePropertyValue

          public boolean handleTypePropertyValue(JsonParser p,
                                                 DeserializationContext ctxt,
                                                 String propName,
                                                 Object bean)
                                          throws IOException

      Method called to see if given property/value pair is an external type id; and if so handle it. This is only to be called in case containing POJO has similarly named property as the external type id AND value is of scalar type: otherwise `handlePropertyValue(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.String, java.lang.Object)` should be called instead.
      Throws:
        `IOException`

    - #### handlePropertyValue

          public boolean handlePropertyValue(JsonParser p,
                                             DeserializationContext ctxt,
                                             String propName,
                                             Object bean)
                                      throws IOException

      Method called to ask handler to handle value of given property, at point where parser points to the first token of the value. Handling can mean either resolving type id it contains (if it matches type property name), or by buffering the value for further use.
      Returns:
        True, if the given property was properly handled
      Throws:
        `IOException`

    - #### complete

          public Object complete(JsonParser p,
                                 DeserializationContext ctxt,
                                 Object bean)
                          throws IOException

      Method called after JSON Object closes, and has to ensure that all external type ids have been handled.
      Throws:
        `IOException`

    - #### complete

          public Object complete(JsonParser p,
                                 DeserializationContext ctxt,
                                 PropertyValueBuffer buffer,
                                 PropertyBasedCreator creator)
                          throws IOException

      Variant called when creation of the POJO involves buffering of creator properties as well as property-based creator.
      Throws:
        `IOException`

    - #### _deserialize

          protected final Object _deserialize(JsonParser p,
                                              DeserializationContext ctxt,
                                              int index,
                                              String typeId)
                                       throws IOException

      Throws:
        `IOException`

    - #### _deserializeAndSet

          protected final void _deserializeAndSet(JsonParser p,
                                                  DeserializationContext ctxt,
                                                  Object bean,
                                                  int index,
                                                  String typeId)
                                           throws IOException

      Throws:
        `IOException`

Copyright © 2008–2020 FasterXML. All rights reserved.