Class AbstractSerializer
java.lang.Object
io.fluxcapacitor.javaclient.common.serialization.AbstractSerializer
- All Implemented Interfaces:
Serializer
- Direct Known Subclasses:
JacksonSerializer
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSerializer(Upcaster<SerializedObject<byte[], ?>> upcasterChain, String format) -
Method Summary
Modifier and TypeMethodDescriptionprotected String<V> V<V> V<S extends SerializedObject<byte[],S>>
Stream<DeserializingObject<byte[],S>> deserialize(Stream<S> dataStream, boolean failOnUnknownType) Upcasts and deserializes a stream of serialized objects.protected Stream<DeserializingObject<byte[],?>> deserializeOtherFormat(SerializedObject<byte[], ?> s) protected Stream<DeserializingObject<byte[],?>> deserializeUnknownType(SerializedObject<byte[], ?> serializedObject) protected abstract Objectprotected abstract <V> Vprotected abstract ObjectdoDeserialize(Data<byte[]> data, String type) protected abstract byte[]doSerialize(Object object) getRevision(Object object) protected Typeprotected booleanisKnownType(String type) registerTypeCaster(String oldType, String newType) Data<byte[]>Serializes an object using the given desiredformatto aDataobject containing a byte array.protected Data<byte[]>serializeToOtherFormat(Object object, String format) upcastType(String type) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluxcapacitor.javaclient.common.serialization.Serializer
deserialize, deserializeMessages, deserializeMessages, serialize
-
Constructor Details
-
AbstractSerializer
-
-
Method Details
-
serialize
Description copied from interface:SerializerSerializes an object using the given desiredformatto aDataobject containing a byte array. If format isnullthe default format of this serializer may be used.- Specified by:
serializein interfaceSerializer- Parameters:
object- The instance to serialize- Returns:
- Data object containing byte array representation of the object
-
serializeToOtherFormat
-
getType
-
asString
-
getRevision
-
doSerialize
- 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
-
convert
- Specified by:
convertin interfaceSerializer
-
clone
- Specified by:
clonein interfaceSerializer
-
registerTypeCaster
- Specified by:
registerTypeCasterin interfaceSerializer
-
upcastType
- Specified by:
upcastTypein interfaceSerializer
-
doClone
-
doConvert
-
isKnownType
-
deserializeOtherFormat
protected Stream<DeserializingObject<byte[],?>> deserializeOtherFormat(SerializedObject<byte[], ?> s) -
deserializeUnknownType
protected Stream<DeserializingObject<byte[],?>> deserializeUnknownType(SerializedObject<byte[], ?> serializedObject) -
doDeserialize
- Throws:
Exception
-