org.qi4j.api.value

## Interface ValueDeserializer

- All Known Subinterfaces:
    JacksonValueSerializationService, OrgJsonValueSerializationService, StaxValueSerializationService, ValueSerialization
  All Known Implementing Classes:
    JacksonValueDeserializer, OrgJsonValueDeserializer, OrgJsonValueSerialization, StaxValueDeserializer, ValueDeserializerAdapter

      public interface ValueDeserializer

  Use a ValueDeserializer to create new values instances from serialized state.

  Serialized state must be one of:

  - a ValueComposite,
  - an EntityReference,
  - a Collection,
  - a Map,
  - a Plain Value.

  Nested plain values, EntityReferences, Collections, Maps, ValueComposites are supported. EntityReferences are deserialized as their identity string.

  Plain values can be one of:

  - String,
  - Character or char,
  - Boolean or boolean,
  - Integer or int,
  - Long or long,
  - Short or short,
  - Byte or byte,
  - Float or float,
  - Double or double,
  - BigInteger,
  - BigDecimal,
  - Date,
  - DateTime (JodaTime),
  - LocalDateTime (JodaTime),
  - LocalDate (JodaTime).

  Values of unknown types and all arrays are considered as `Serializable` and by so are deserialized from base64 encoded bytes using pure Java serialization. If it happens that the input is invalid, a ValueSerializationException is thrown.

  Having type information in the serialized payload allows to keep actual ValueComposite types and by so circumvent `AmbiguousTypeException` when deserializing.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> Function2<ValueType,String,T>` | `deserialize()` Factory method for an untyped deserialize function.
    `<T> T` | `deserialize(Class<?> type, InputStream input)` Deserialize a value from a state.
    `<T> T` | `deserialize(Class<?> type, String input)` Deserialize a value from a state.
    `<T> Function<String,T>` | `deserialize(Class<T> type)` Factory method for a typed deserialize function.
    `<T> Function<String,T>` | `deserialize(ValueType valueType)` Factory method for a typed deserialize function.
    `<T> T` | `deserialize(ValueType valueType, InputStream input)` Deserialize a value from a state.
    `<T> T` | `deserialize(ValueType valueType, String input)` Deserialize a value from a state.

- - ### Method Detail

    - #### deserialize

          <T> Function<String,T> deserialize(Class<T> type)

      Factory method for a typed deserialize function.

      The returned Function may throw `ValueSerializationException`.

      Type Parameters:
        `T` - the parametrized function return type
      Parameters:
        `type` - the value type
      Returns:
        a deserialization function

    - #### deserialize

          <T> Function<String,T> deserialize(ValueType valueType)

      Factory method for a typed deserialize function.

      The returned Function may throw `ValueSerializationException`.

      Type Parameters:
        `T` - the parametrized function return type
      Parameters:
        `valueType` - the value type
      Returns:
        a deserialization function

    - #### deserialize

          <T> Function2<ValueType,String,T> deserialize()

      Factory method for an untyped deserialize function.

      The returned Function may throw `ValueSerializationException`.

      Type Parameters:
        `T` - the parametrized function return type
      Returns:
        a deserialization function

    - #### deserialize

          <T> T deserialize(Class<?> type,
                          String input)
                        throws ValueSerializationException

      Deserialize a value from a state.
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `type` - the value type
        `input` - the state
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed

    - #### deserialize

          <T> T deserialize(ValueType valueType,
                          String input)
                        throws ValueSerializationException

      Deserialize a value from a state.
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `valueType` - the value type
        `input` - the state
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed

    - #### deserialize

          <T> T deserialize(Class<?> type,
                          InputStream input)
                        throws ValueSerializationException

      Deserialize a value from a state.
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `type` - the value type
        `input` - the state stream
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed

    - #### deserialize

          <T> T deserialize(ValueType valueType,
                          InputStream input)
                        throws ValueSerializationException

      Deserialize a value from a state.
      Type Parameters:
        `T` - the parametrized returned type
      Parameters:
        `valueType` - the value type
        `input` - the state stream
      Returns:
        the value
      Throws:
        `ValueSerializationException` - if the deserialization failed