Class InitialEventRepresentation
java.lang.Object
org.axonframework.serialization.upcasting.event.InitialEventRepresentation
- All Implemented Interfaces:
IntermediateEventRepresentation
Implementation of an
IntermediateEventRepresentation that contains the original serialized payload and
metadata before these have been upcast. Usually there is one InitialEventRepresentation per event entry from
the data store.- Since:
- 3.0
- Author:
- Rene de Waele
-
Constructor Summary
ConstructorsConstructorDescriptionInitialEventRepresentation(EventData<?> eventData, Serializer serializer) Initializes anInitialEventRepresentationfrom the giveneventData. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanConvertDataTo(Class<?> requiredType) Checks if the data can be converted to the givenrequiredType.Returns the Identifier of the Aggregate to which the Event owning the object to upcast, was applied.Returns the Type of the Aggregate to which the Event owning the object to upcast, was applied.Class<?> Returns the type of this representation'sdata.getData()Get the data of this representation.<D> SerializedObject<D> Get the data of this representation.Returns the identifier of the message wrapping the object to upcast.Returns the meta data of the message wrapping the object being upcast.Returns the sequence number of the event in the aggregate, or an empty Optional if the message wrapping the object being upcast does not contain a sequence number.Returns the timestamp at which the event was first created.Returns the tracking token of the event, or an empty Optional if the message wrapping the object being upcast does not contain a tracking token.getType()Returns the type and version of the data contained in this representation.upcast(SerializedType outputType, Class<T> expectedRepresentationType, Function<T, T> upcastFunction, Function<MetaData, MetaData> metaDataUpcastFunction) Upcast the serialized payload of the event (leaving other aspects of the event the same).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation
upcastPayload
-
Constructor Details
-
InitialEventRepresentation
Initializes anInitialEventRepresentationfrom the giveneventData. The providedserializeris used to deserialize metadata if the metadata is required during upcasting. The serializer also provides theConverterused to convert serialized data from one format to another if required by any upcaster.- Parameters:
eventData- the serialized event dataserializer- the serializer to deserialize metadata and provide the converter factory
-
-
Method Details
-
upcast
public <T> IntermediateEventRepresentation upcast(SerializedType outputType, Class<T> expectedRepresentationType, Function<T, T> upcastFunction, Function<MetaData, MetaData> metaDataUpcastFunction) Description copied from interface:IntermediateEventRepresentationUpcast the serialized payload of the event (leaving other aspects of the event the same).- Specified by:
upcastin interfaceIntermediateEventRepresentation- Type Parameters:
T- The expected payload type before and after upcasting- Parameters:
outputType- The output type of the event after upcastingexpectedRepresentationType- The type of the serialized payload required by the upcast functionupcastFunction- The upcast function for the event's payloadmetaDataUpcastFunction- The upcast function for the event's metadata- Returns:
- The intermediate representation of the event after upcasting
-
getType
Description copied from interface:IntermediateEventRepresentationReturns the type and version of the data contained in this representation.- Specified by:
getTypein interfaceIntermediateEventRepresentation- Returns:
- the type and version of the represented data
-
getData
Description copied from interface:IntermediateEventRepresentationGet the data of this representation. The type of the returned data should match that ofIntermediateEventRepresentation.getType().- Specified by:
getDatain interfaceIntermediateEventRepresentation- Returns:
- the data representation of the object
-
getData
Description copied from interface:IntermediateEventRepresentationGet the data of this representation. The type of the returned data will be converted to the givenrequiredType.- Specified by:
getDatain interfaceIntermediateEventRepresentation- Parameters:
requiredType- the type to convert to- Returns:
- the data representation of the object converted to the required type
-
getContentType
Description copied from interface:IntermediateEventRepresentationReturns the type of this representation'sdata.- Specified by:
getContentTypein interfaceIntermediateEventRepresentation- Returns:
- The type of this representation's
data.
-
getMessageIdentifier
Description copied from interface:IntermediateEventRepresentationReturns the identifier of the message wrapping the object to upcast.- Specified by:
getMessageIdentifierin interfaceIntermediateEventRepresentation- Returns:
- the identifier of the message wrapping the object to upcast
-
getAggregateType
Description copied from interface:IntermediateEventRepresentationReturns the Type of the Aggregate to which the Event owning the object to upcast, was applied. This will return an empty Optional if the object being upcast was not contained in a DomainEventMessage.- Specified by:
getAggregateTypein interfaceIntermediateEventRepresentation- Returns:
- the Type of the Aggregate to which the Event was applied, or an empty Optional if not applicable
-
getAggregateIdentifier
Description copied from interface:IntermediateEventRepresentationReturns the Identifier of the Aggregate to which the Event owning the object to upcast, was applied. This will return an empty Optional if the object being upcast was not contained in a DomainEventMessage.- Specified by:
getAggregateIdentifierin interfaceIntermediateEventRepresentation- Returns:
- the Identifier of the Aggregate to which the Event was applied, or an empty Optional if not applicable
-
getSequenceNumber
Description copied from interface:IntermediateEventRepresentationReturns the sequence number of the event in the aggregate, or an empty Optional if the message wrapping the object being upcast does not contain a sequence number.- Specified by:
getSequenceNumberin interfaceIntermediateEventRepresentation- Returns:
- the sequence number of the event in the aggregate, or an empty Optional if not applicable
-
getTrackingToken
Description copied from interface:IntermediateEventRepresentationReturns the tracking token of the event, or an empty Optional if the message wrapping the object being upcast does not contain a tracking token.- Specified by:
getTrackingTokenin interfaceIntermediateEventRepresentation- Returns:
- the tracking token of the event, or an empty Optional if not applicable
-
getTimestamp
Description copied from interface:IntermediateEventRepresentationReturns the timestamp at which the event was first created. Will returnnullif the object being upcast- Specified by:
getTimestampin interfaceIntermediateEventRepresentation- Returns:
- the timestamp at which the event was first created, if available
-
getMetaData
Description copied from interface:IntermediateEventRepresentationReturns the meta data of the message wrapping the object being upcast. If the meta data is not available, or is in fact the subject of being upcast itself, this method returnsnull.- Specified by:
getMetaDatain interfaceIntermediateEventRepresentation- Returns:
- the MetaData of the message wrapping the object to upcast, if available
-
canConvertDataTo
Description copied from interface:IntermediateEventRepresentationChecks if the data can be converted to the givenrequiredType.- Specified by:
canConvertDataToin interfaceIntermediateEventRepresentation- Parameters:
requiredType- the type to validate if the contained data can be converted to.- Returns:
- true, if the intermediate representation's data can be converted to desired type, false otherwise
-