Class UpcastedEventRepresentation<T>
java.lang.Object
org.axonframework.serialization.upcasting.event.UpcastedEventRepresentation<T>
- Type Parameters:
T- the required type of the serialized data. If the data is not of this type the representation uses aConverterto convert to the required type.
- All Implemented Interfaces:
IntermediateEventRepresentation
public class UpcastedEventRepresentation<T>
extends Object
implements IntermediateEventRepresentation
Implementation of an
IntermediateEventRepresentation that contains upcast functions for the payload and
metadata of a previous representation. Note that the upcast functions are to go from one representation to another
(never to more than one). In other words, the upcast functions stored in the UpcastedEventRepresentation are not
mapping one to one to the upcast method of an upcaster.- Since:
- 3.0
- Author:
- Rene de Waele
-
Constructor Summary
ConstructorsConstructorDescriptionUpcastedEventRepresentation(SerializedType outputType, IntermediateEventRepresentation source, Function<T, T> upcastFunction, Function<MetaData, MetaData> metaDataUpcastFunction, Class<T> requiredType, Converter converter) Initializes anUpcastedEventRepresentationfrom source data and given upcast functions for payload and metadata. -
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<S> expectedRepresentationType, Function<S, S> 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
-
UpcastedEventRepresentation
public UpcastedEventRepresentation(SerializedType outputType, IntermediateEventRepresentation source, Function<T, T> upcastFunction, Function<MetaData, MetaData> metaDataUpcastFunction, Class<T> requiredType, Converter converter) Initializes anUpcastedEventRepresentationfrom source data and given upcast functions for payload and metadata. The givenconverteris used to convert to the serialized data format required by the upcast functions.- Parameters:
outputType- the output type of the payload data after upcastingsource- the intermediate representation that will be upcastupcastFunction- the function to upcast the payload datametaDataUpcastFunction- the function to upcast the metadatarequiredType- the type that is needed for the upcastFunctionconverter- produces converters to convert the serialized data type if required
-
-
Method Details
-
upcast
public <S> IntermediateEventRepresentation upcast(SerializedType outputType, Class<S> expectedRepresentationType, Function<S, S> 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:
S- 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
-