public interface Serializer
| Modifier and Type | Method and Description |
|---|---|
default <T> T |
deserialize(Data<byte[]> data)
Upcasts and deserializes the given
Data object to an object of type T. |
<I extends SerializedObject<byte[],I>> |
deserialize(Stream<I> dataStream,
boolean failOnUnknownType)
Upcasts and deserializes a stream of serialized objects.
|
Data<byte[]> |
serialize(Object object)
Serializes an object to a
Data object containing a byte array. |
Data<byte[]> serialize(Object object)
Data object containing a byte array.object - The instance to serializeSerializationException - if serialization failsdefault <T> T deserialize(Data<byte[]> data)
Data object to an object of type T. If the input data cannot
be deserialized to a single result (due to upcasting) a SerializationException is thrown.T - Type of object to deserialize todata - Data to deserializeSerializationException - if deserialization fails<I extends SerializedObject<byte[],I>> Stream<DeserializingObject<byte[],I>> deserialize(Stream<I> dataStream, boolean failOnUnknownType)
Deserialization is performed lazily. This means that actual conversion for a given result in the output stream
only happens if DeserializingObject.getPayload() is invoked on the result. This has the advantage that a
caller can inspect what type will be returned via DeserializingObject.getSerializedObject() before
deciding to go through with the deserialization.
You can specify whether deserialization of a result in the output stream should fail with a SerializationException if a type is unknown (not a class). It is up to the implementation to determine what
should happen if a type is unknown but the failOnUnknownType flag is false.
I - the type of the serialized objectdataStream - data input stream to deserializefailOnUnknownType - flag that determines whether deserialization of an unknown type should give an
exceptionCopyright © 2019 Flux Capacitor. All rights reserved.