Class AbstractSerializer
- java.lang.Object
-
- io.fluxcapacitor.javaclient.common.serialization.AbstractSerializer
-
- All Implemented Interfaces:
Serializer
- Direct Known Subclasses:
JacksonSerializer
public abstract class AbstractSerializer extends Object implements Serializer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractSerializer.NullValue
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSerializer(Upcaster<SerializedObject<byte[],?>> upcasterChain)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Class<?>classForType(String type)<S extends SerializedObject<byte[],S>>
Stream<DeserializingObject<byte[],S>>deserialize(Stream<S> dataStream, boolean failOnUnknownType)Upcasts and deserializes a stream of serialized objects.protected abstract ObjectdoDeserialize(byte[] bytes, Class<?> type)protected abstract byte[]doSerialize(Object object)protected StringgetObjectType(Object object)protected RevisiongetRevision(Object object)protected Stream<DeserializingObject<byte[],?>>handleUnknownType(SerializedObject<byte[],?> serializedObject)Data<byte[]>serialize(Object object)Serializes an object to aDataobject containing a byte array.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.fluxcapacitor.javaclient.common.serialization.Serializer
deserialize, deserializeMessages
-
-
-
-
Constructor Detail
-
AbstractSerializer
protected AbstractSerializer(Upcaster<SerializedObject<byte[],?>> upcasterChain)
-
-
Method Detail
-
serialize
public Data<byte[]> serialize(Object object)
Description copied from interface:SerializerSerializes an object to aDataobject containing a byte array.- Specified by:
serializein interfaceSerializer- Parameters:
object- The instance to serialize- Returns:
- Data object containing byte array representation of the object
-
doSerialize
protected abstract byte[] doSerialize(Object object) throws Exception
- Throws:
Exception
-
deserialize
public <S extends SerializedObject<byte[],S>> Stream<DeserializingObject<byte[],S>> deserialize(Stream<S> dataStream, boolean failOnUnknownType)
Description copied from interface:SerializerUpcasts 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 viaDeserializingObject.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
SerializationExceptionif a type is unknown (not a class). It is up to the implementation to determine what should happen if a type is unknown but thefailOnUnknownTypeflag is false.- Specified by:
deserializein interfaceSerializer- Type Parameters:
S- the type of the serialized object- Parameters:
dataStream- data input stream to deserializefailOnUnknownType- flag that determines whether deserialization of an unknown type should give an exception- Returns:
- a stream containing deserialization results
-
handleUnknownType
protected Stream<DeserializingObject<byte[],?>> handleUnknownType(SerializedObject<byte[],?> serializedObject)
-
-