Package org.axonframework.serialization
Class LazyDeserializingObject<T>
java.lang.Object
org.axonframework.serialization.LazyDeserializingObject<T>
- Type Parameters:
T- The type of object contained in the serialized 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 Summary
ConstructorsConstructorDescriptionLazyDeserializingObject(Supplier<SerializedObject<?>> serializedObjectSupplier, SerializedType serializedType, Serializer serializer) Creates an instance which will get the supplied SerializedObject and deserialize it upon request.LazyDeserializingObject(SerializedObject<?> serializedObject, Serializer serializer) Creates an instance which will deserialize givenserializedObjectupon request.LazyDeserializingObject(T deserializedObject) Creates an instance with the givendeserializedObjectobject instance. -
Method Summary
Modifier and TypeMethodDescriptionDe-serializes the object and returns the result.Returns the serialized object to deserialize upon requestReturns the serializer to deserialize this objectgetType()Returns the class of the serialized object.booleanIndicates whether this object has already been deserialized.
-
Constructor Details
-
LazyDeserializingObject
Creates an instance with the givendeserializedObjectobject instance. Using this constructor will ensure that no deserializing is required when invoking thegetType()orgetObject()methods.- Parameters:
deserializedObject- The deserialized object to return ongetObject()
-
LazyDeserializingObject
Creates an instance which will deserialize givenserializedObjectupon request. Use this constructor if theserializedObjectis already available and does not need to undergo a process of e.g. upcasting.- Parameters:
serializedObject- The serialized payload of the messageserializer- 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 objectserializedType- The type of the serialized objectserializer- The serializer to deserialize the payload data with
-
-
Method Details
-
getType
Returns the class of the serialized object.- Returns:
- the class of the serialized object
-
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 returnstrue, thegetObject()method is able to return a value without invoking the serializer.- Returns:
- whether the contained object has been deserialized already.
-
getSerializer
Returns the serializer to deserialize this object- Returns:
- the serializer to deserialize this object
-
getSerializedObject
Returns the serialized object to deserialize upon request- Returns:
- the serialized object to deserialize upon request
-