Class LazyDeserializingObject<T>

java.lang.Object
org.axonframework.serialization.LazyDeserializingObject<T>
Type Parameters:
T - The type of object contained in the serialized object

public class LazyDeserializingObject<T> extends Object
Represents a serialized object that can be deserializedObjects upon request. Typically used as a wrapper class for keeping a SerializedObject and its Serializer together.
Since:
2.0
Author:
Allard Buijze, Frank Versnel
  • Constructor Details

    • LazyDeserializingObject

      public LazyDeserializingObject(T deserializedObject)
      Creates an instance with the given deserializedObject object instance. Using this constructor will ensure that no deserializing is required when invoking the getType() or getObject() methods.
      Parameters:
      deserializedObject - The deserialized object to return on getObject()
    • LazyDeserializingObject

      public LazyDeserializingObject(SerializedObject<?> serializedObject, Serializer serializer)
      Creates an instance which will deserialize given serializedObject upon request. Use this constructor if the serializedObject is already available and does not need to undergo a process of e.g. upcasting.
      Parameters:
      serializedObject - The serialized payload of the message
      serializer - The serializer to deserialize the payload data with
    • LazyDeserializingObject

      public LazyDeserializingObject(Supplier<SerializedObject<?>> serializedObjectSupplier, SerializedType serializedType, Serializer serializer)
      Creates an instance which will get the supplied SerializedObject and deserialize it upon request. Use this constructor if getting the SerializedObject is an 'expensive operation', e.g. if the SerializedObject still needs to be upcasted.
      Parameters:
      serializedObjectSupplier - The supplier of the serialized object
      serializedType - The type of the serialized object
      serializer - The serializer to deserialize the payload data with
  • Method Details

    • getType

      public Class<T> getType()
      Returns the class of the serialized object.
      Returns:
      the class of the serialized object
    • getObject

      public T getObject()
      De-serializes the object and returns the result.
      Returns:
      the deserialized object
    • isDeserialized

      public boolean isDeserialized()
      Indicates whether this object has already been deserialized. When this method returns true, the getObject() method is able to return a value without invoking the serializer.
      Returns:
      whether the contained object has been deserialized already.
    • getSerializer

      public Serializer getSerializer()
      Returns the serializer to deserialize this object
      Returns:
      the serializer to deserialize this object
    • getSerializedObject

      public SerializedObject<?> getSerializedObject()
      Returns the serialized object to deserialize upon request
      Returns:
      the serialized object to deserialize upon request