org.qi4j.api.value

## Interface ValueSerializer

- All Known Subinterfaces:
    JacksonValueSerializationService, OrgJsonValueSerializationService, StaxValueSerializationService, ValueSerialization
  All Known Implementing Classes:
    JacksonValueSerializer, OrgJsonValueSerialization, OrgJsonValueSerializer, StaxValueSerializer, ValueSerializerAdapter

      public interface ValueSerializer

  Use a ValueSerializer to serialize values state.

  Serialized object must be one of:

  - a ValueComposite,
  - an EntityComposite or EntityReference,
  - an Iterable,
  - a Map,
  - a Plain Value.

  Nested plain values, EntityReferences, Iterables, Maps, ValueComposites and EntityComposites are supported. EntityComposites and EntityReferences are serialized 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 serialized to base64 encoded bytes using pure Java serialization. If it happens that the value is not Serializable, a ValueSerializationException is thrown.

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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `ValueSerializer.Options` Serialization options.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> Function<T,String>` | `serialize()` Factory method for a serialize function.
    `<T> Function<T,String>` | `serialize(boolean includeTypeInfo)` Deprecated.
    `String` | `serialize(Object object)` Serialize the state of a value with type information.
    `String` | `serialize(Object object, boolean includeTypeInfo)` Deprecated.
    `void` | `serialize(Object object, OutputStream output)` Serialize the state of a value with type information.
    `void` | `serialize(Object object, OutputStream output, boolean includeTypeInfo)` Deprecated.
    `<T> Function<T,String>` | `serialize(ValueSerializer.Options options)` Factory method for a serialize function.
    `String` | `serialize(ValueSerializer.Options options, Object object)` Serialize the state of a value.
    `void` | `serialize(ValueSerializer.Options options, Object object, OutputStream output)` Serialize the state of a value.

- - ### Method Detail

    - #### serialize

          <T> Function<T,String> serialize()

      Factory method for a serialize function.
      Type Parameters:
        `T` - the parametrized function input type
      Returns:
        a serialization function.

    - #### serialize

          <T> Function<T,String> serialize(ValueSerializer.Options options)

      Factory method for a serialize function.
      Type Parameters:
        `T` - the parametrized function input type
      Parameters:
        `options` - ValueSerializer Options
      Returns:
        a serialization function.

    - #### serialize

          @Deprecated
          <T> Function<T,String> serialize(boolean includeTypeInfo)

      Deprecated.
      Factory method for a serialize function.
      Type Parameters:
        `T` - the parametrized function input type
      Parameters:
        `includeTypeInfo` - if type information should be included in the output
      Returns:
        a serialization function.

    - #### serialize

          String serialize(Object object)
                           throws ValueSerializationException

      Serialize the state of a value with type information.
      Parameters:
        `object` - an Object to serialize
      Returns:
        the state
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          String serialize(ValueSerializer.Options options,
                         Object object)
                           throws ValueSerializationException

      Serialize the state of a value.
      Parameters:
        `options` - ValueSerializer Options
        `object` - an Object to serialize
      Returns:
        the state
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          @Deprecated
          String serialize(Object object,
                                    boolean includeTypeInfo)
                           throws ValueSerializationException

      Deprecated.
      Serialize the state of a value.
      Parameters:
        `object` - an Object to serialize
        `includeTypeInfo` - if type information should be included in the output
      Returns:
        the state
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          void serialize(Object object,
                       OutputStream output)
                         throws ValueSerializationException

      Serialize the state of a value with type information.
      Parameters:
        `object` - an Object to serialize
        `output` - that will be used as output
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          void serialize(ValueSerializer.Options options,
                       Object object,
                       OutputStream output)
                         throws ValueSerializationException

      Serialize the state of a value.
      Parameters:
        `options` - ValueSerializer Options
        `object` - an Object to serialize
        `output` - that will be used as output
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          @Deprecated
          void serialize(Object object,
                                  OutputStream output,
                                  boolean includeTypeInfo)
                         throws ValueSerializationException

      Deprecated.
      Serialize the state of a value.
      Parameters:
        `object` - an Object to serialize
        `output` - that will be used as output
        `includeTypeInfo` - if type information should be included in the output
      Throws:
        `ValueSerializationException` - if the Value serialization failed