org.qi4j.valueserialization.jackson

## Class JacksonValueDeserializer

- java.lang.Object
- - org.qi4j.spi.value.ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>
  - - org.qi4j.valueserialization.jackson.JacksonValueDeserializer

- All Implemented Interfaces:
    ValueDeserializer

      public class JacksonValueDeserializer
      extends ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>

  ValueDeserializer reading Values from JSON documents using Jackson.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.qi4j.spi.value.ValueDeserializerAdapter

      `ValueDeserializerAdapter.ComplexDeserializer<T,InputType,InputNodeType>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JacksonValueDeserializer(Application application, Module module, ServiceReference<ValueDeserializer> serviceRef)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected com.fasterxml.jackson.core.JsonParser` | `adaptInput(InputStream input)` This method is always called first, this is a chance to wrap the input type.
    `protected Object` | `asSimpleValue(com.fasterxml.jackson.databind.JsonNode inputNode)`
    `protected <T> T` | `getObjectFieldValue(com.fasterxml.jackson.databind.JsonNode inputNode, String key, Function<com.fasterxml.jackson.databind.JsonNode,T> valueDeserializer)` Return null if the field do not exists.
    `protected boolean` | `isObjectValue(com.fasterxml.jackson.databind.JsonNode inputNode)`
    `protected boolean` | `objectHasField(com.fasterxml.jackson.databind.JsonNode inputNode, String key)`
    `protected void` | `onDeserializationEnd(ValueType valueType, com.fasterxml.jackson.core.JsonParser input)` Called by the adapter on deserialization end.
    `protected <T> void` | `putArrayNodeInCollection(com.fasterxml.jackson.databind.JsonNode inputNode, Function<com.fasterxml.jackson.databind.JsonNode,T> deserializer, Collection<T> collection)`
    `protected <K,V> void` | `putArrayNodeInMap(com.fasterxml.jackson.databind.JsonNode inputNode, Function<com.fasterxml.jackson.databind.JsonNode,K> keyDeserializer, Function<com.fasterxml.jackson.databind.JsonNode,V> valueDeserializer, Map<K,V> map)`
    `protected <V> void` | `putObjectNodeInMap(com.fasterxml.jackson.databind.JsonNode inputNode, Function<com.fasterxml.jackson.databind.JsonNode,V> valueDeserializer, Map<String,V> map)`
    `protected <T> Collection<T>` | `readArrayInCollection(com.fasterxml.jackson.core.JsonParser input, Function<com.fasterxml.jackson.core.JsonParser,T> deserializer, Collection<T> collection)`
    `protected <K,V> Map<K,V>` | `readMapInMap(com.fasterxml.jackson.core.JsonParser input, Function<com.fasterxml.jackson.core.JsonParser,K> keyDeserializer, Function<com.fasterxml.jackson.core.JsonParser,V> valueDeserializer, Map<K,V> map)` A Map<K,V> is serialized in an array of entries objects.
    `protected com.fasterxml.jackson.databind.node.ObjectNode` | `readObjectTree(com.fasterxml.jackson.core.JsonParser input)`
    `protected Object` | `readPlainValue(com.fasterxml.jackson.core.JsonParser input)`

    - ### Methods inherited from class org.qi4j.spi.value.ValueDeserializerAdapter

      `deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, onDeserializationStart, registerComplexDeserializer, registerDeserializer`

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

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

- - ### Constructor Detail

    - #### JacksonValueDeserializer

          public JacksonValueDeserializer(@Structure
                                  Application application,
                                  @Structure
                                  Module module,
                                  @Service
                                  ServiceReference<ValueDeserializer> serviceRef)

  - ### Method Detail

    - #### adaptInput

          protected com.fasterxml.jackson.core.JsonParser adaptInput(InputStream input)
                                                              throws Exception

      Description copied from class: `ValueDeserializerAdapter`
      This method is always called first, this is a chance to wrap the input type.
      Specified by:
        `adaptInput` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Parameters:
        `input` - InputStream to adapt
      Returns:
        Adapted input
      Throws:
        `Exception` - that will be wrapped in a `ValueSerializationException`

    - #### onDeserializationEnd

          protected void onDeserializationEnd(ValueType valueType,
                                  com.fasterxml.jackson.core.JsonParser input)
                                       throws Exception

      Description copied from class: `ValueDeserializerAdapter`
      Called by the adapter on deserialization end.
      Overrides:
        `onDeserializationEnd` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Parameters:
        `valueType` - ValueType
        `input` - Input
      Throws:
        `Exception` - that will be wrapped in a `ValueSerializationException`

    - #### readPlainValue

          protected Object readPlainValue(com.fasterxml.jackson.core.JsonParser input)
                                   throws Exception

      Specified by:
        `readPlainValue` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Parameters:
        `input` - Input
      Returns:
        a Plain Value read from the input
      Throws:
        `Exception` - that will be wrapped in a `ValueSerializationException`

    - #### readArrayInCollection

          protected <T> Collection<T> readArrayInCollection(com.fasterxml.jackson.core.JsonParser input,
                                                Function<com.fasterxml.jackson.core.JsonParser,T> deserializer,
                                                Collection<T> collection)
                                                 throws Exception

      Specified by:
        `readArrayInCollection` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Type Parameters:
        `T` - Parameterized collection type
      Parameters:
        `input` - Input
        `deserializer` - Deserialization function
        `collection` - Collection
      Returns:
        The filled collection or null if no array
      Throws:
        `Exception` - that will be wrapped in a `ValueSerializationException`

    - #### readMapInMap

          protected <K,V> Map<K,V> readMapInMap(com.fasterxml.jackson.core.JsonParser input,
                                    Function<com.fasterxml.jackson.core.JsonParser,K> keyDeserializer,
                                    Function<com.fasterxml.jackson.core.JsonParser,V> valueDeserializer,
                                    Map<K,V> map)
                                   throws Exception

      Description copied from class: `ValueDeserializerAdapter`
      A Map<K,V> is serialized in an array of entries objects.

      Here is an example in JSON:

           [
               { "key": "foo",       "value": "bar"   },
               { "key": "cathedral", "value": "bazar" }
           ]

      And an empty Map:

          []

      This allow to use any type as keys and values while keeping the Map order at the cost of having non-predictible order of key/value inside an entry object.

      Specified by:
        `readMapInMap` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Type Parameters:
        `K` - Parameterized map key type
        `V` - Parameterized map value type
      Parameters:
        `input` - Input
        `keyDeserializer` - Map key deserialization function
        `valueDeserializer` - Map value deserialization function
        `map` - Map
      Returns:
        The filled map or null if no array
      Throws:
        `Exception` - that will be wrapped in a `ValueSerializationException`

    - #### readObjectTree

          protected com.fasterxml.jackson.databind.node.ObjectNode readObjectTree(com.fasterxml.jackson.core.JsonParser input)
                                                                           throws Exception

      Specified by:
        `readObjectTree` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Parameters:
        `input` - Input
      Returns:
        an InputNodeType or null if the value was null
      Throws:
        `Exception` - that will be wrapped in a `ValueSerializationException`

    - #### asSimpleValue

          protected Object asSimpleValue(com.fasterxml.jackson.databind.JsonNode inputNode)
                                  throws Exception

      Specified by:
        `asSimpleValue` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Throws:
        `Exception`

    - #### isObjectValue

          protected boolean isObjectValue(com.fasterxml.jackson.databind.JsonNode inputNode)
                                   throws Exception

      Specified by:
        `isObjectValue` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Throws:
        `Exception`

    - #### objectHasField

          protected boolean objectHasField(com.fasterxml.jackson.databind.JsonNode inputNode,
                               String key)
                                    throws Exception

      Specified by:
        `objectHasField` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Throws:
        `Exception`

    - #### getObjectFieldValue

          protected <T> T getObjectFieldValue(com.fasterxml.jackson.databind.JsonNode inputNode,
                                  String key,
                                  Function<com.fasterxml.jackson.databind.JsonNode,T> valueDeserializer)
                                   throws Exception

      Description copied from class: `ValueDeserializerAdapter`
      Return null if the field do not exists.
      Specified by:
        `getObjectFieldValue` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Type Parameters:
        `T` - Parameterized object field value type
      Parameters:
        `inputNode` - Input Node
        `key` - Object key
        `valueDeserializer` - Deserialization function
      Returns:
        The value of the field.
      Throws:
        `Exception` - that will be wrapped in a `ValueSerializationException`

    - #### putArrayNodeInCollection

          protected <T> void putArrayNodeInCollection(com.fasterxml.jackson.databind.JsonNode inputNode,
                                          Function<com.fasterxml.jackson.databind.JsonNode,T> deserializer,
                                          Collection<T> collection)
                                           throws Exception

      Specified by:
        `putArrayNodeInCollection` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Throws:
        `Exception`

    - #### putArrayNodeInMap

          protected <K,V> void putArrayNodeInMap(com.fasterxml.jackson.databind.JsonNode inputNode,
                                     Function<com.fasterxml.jackson.databind.JsonNode,K> keyDeserializer,
                                     Function<com.fasterxml.jackson.databind.JsonNode,V> valueDeserializer,
                                     Map<K,V> map)
                                    throws Exception

      Specified by:
        `putArrayNodeInMap` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Throws:
        `Exception`

    - #### putObjectNodeInMap

          protected <V> void putObjectNodeInMap(com.fasterxml.jackson.databind.JsonNode inputNode,
                                    Function<com.fasterxml.jackson.databind.JsonNode,V> valueDeserializer,
                                    Map<String,V> map)
                                     throws Exception

      Specified by:
        `putObjectNodeInMap` in class `ValueDeserializerAdapter<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.JsonNode>`
      Throws:
        `Exception`