Interface Serializer

    • Method Detail

      • serialize

        Data<byte[]> serialize​(Object object)
        Serializes an object to a Data object containing a byte array.
        Parameters:
        object - The instance to serialize
        Returns:
        Data object containing byte array representation of the object
        Throws:
        SerializationException - if serialization fails
      • deserialize

        default <T> T deserialize​(Data<byte[]> data)
        Upcasts and deserializes the given 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.
        Type Parameters:
        T - Type of object to deserialize to
        Parameters:
        data - Data to deserialize
        Returns:
        Object resulting from the deserialization
        Throws:
        SerializationException - if deserialization fails
      • deserialize

        <I extends SerializedObject<byte[],​I>> Stream<DeserializingObject<byte[],​I>> deserialize​(Stream<I> dataStream,
                                                                                                             boolean failOnUnknownType)
        Upcasts and deserializes a stream of serialized objects. Each result in the output stream contains both a provider for the deserialized object and the serialized object after upcasting that is used as the source of the deserialized object.

        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.

        Type Parameters:
        I - the type of the serialized object
        Parameters:
        dataStream - data input stream to deserialize
        failOnUnknownType - flag that determines whether deserialization of an unknown type should give an exception
        Returns:
        a stream containing deserialization results