org.qi4j.api.value
Interface ValueDeserializer

All Known Subinterfaces:
OrgJsonValueSerializationService, ValueSerialization
All Known Implementing Classes:
OrgJsonValueDeserializer, OrgJsonValueSerialization, ValueDeserializerAdapter

public interface ValueDeserializer

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

Serialized state must be one of:

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

Plain values can be one of:

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
<T> Function2<ValueType,java.lang.String,T>
deserialize()
          Factory method for an untyped deserialize function.
<T> T
deserialize(java.lang.Class<?> type, java.io.InputStream input)
          Deserialize a value from a state.
<T> T
deserialize(java.lang.Class<?> type, java.lang.String input)
          Deserialize a value from a state.
<T> Function<java.lang.String,T>
deserialize(java.lang.Class<T> type)
          Factory method for a typed deserialize function.
<T> Function<java.lang.String,T>
deserialize(ValueType valueType)
          Factory method for a typed deserialize function.
<T> T
deserialize(ValueType valueType, java.io.InputStream input)
          Deserialize a value from a state.
<T> T
deserialize(ValueType valueType, java.lang.String input)
          Deserialize a value from a state.
 

Method Detail

deserialize

<T> Function<java.lang.String,T> deserialize(java.lang.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<java.lang.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,java.lang.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(java.lang.Class<?> type,
                  java.lang.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,
                  java.lang.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(java.lang.Class<?> type,
                  java.io.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,
                  java.io.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