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
  • Constructor Details

  • Method Details

    • serialize

      public Data<byte[]> serialize(Object object, String format)
      Description copied from interface: Serializer
      Serializes an object using the given desired format to a Data object containing a byte array. If format is null the default format of this serializer may be used.
      Specified by:
      serialize in interface Serializer
      Parameters:
      object - The instance to serialize
      Returns:
      Data object containing byte array representation of the object
    • serializeToOtherFormat

      protected Data<byte[]> serializeToOtherFormat(Object object, String format)
    • getType

      protected Type getType(Object object)
    • asString

      protected String asString(Type type)
    • getRevision

      protected Optional<Revision> getRevision(Object 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: Serializer
      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.

      Specified by:
      deserialize in interface Serializer
      Type Parameters:
      S - 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
    • convert

      public <V> V convert(Object value, Class<V> type)
      Specified by:
      convert in interface Serializer
    • clone

      public <V> V clone(Object value)
      Specified by:
      clone in interface Serializer
    • registerTypeCaster

      public Serializer registerTypeCaster(String oldType, String newType)
      Specified by:
      registerTypeCaster in interface Serializer
    • upcastType

      public String upcastType(String type)
      Specified by:
      upcastType in interface Serializer
    • doClone

      protected abstract Object doClone(Object value)
    • doConvert

      protected abstract <V> V doConvert(Object value, Class<V> type)
    • isKnownType

      protected boolean isKnownType(String type)
    • deserializeOtherFormat

      protected Stream<DeserializingObject<byte[],?>> deserializeOtherFormat(SerializedObject<byte[],?> s)
    • deserializeUnknownType

      protected Stream<DeserializingObject<byte[],?>> deserializeUnknownType(SerializedObject<byte[],?> serializedObject)
    • doDeserialize

      protected abstract Object doDeserialize(Data<byte[]> data, String type) throws Exception
      Throws:
      Exception