Interface IntermediateEventRepresentation
- All Known Implementing Classes:
InitialEventRepresentation,UpcastedEventRepresentation
public interface IntermediateEventRepresentation
Interface describing the intermediate representation of an event during upcasting.
- Since:
- 3.0
- Author:
- Rene de Waele
-
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.default 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).default <T> IntermediateEventRepresentationupcastPayload(SerializedType outputType, Class<T> expectedRepresentationType, Function<T, T> upcastFunction) Upcast the serialized payload of the event (leaving other aspects of the event the same).
-
Method Details
-
upcastPayload
default <T> IntermediateEventRepresentation upcastPayload(SerializedType outputType, Class<T> expectedRepresentationType, Function<T, T> upcastFunction) Upcast the serialized payload of the event (leaving other aspects of the event the same).- 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 payload- Returns:
- The intermediate representation of the event after upcasting
-
upcast
<T> IntermediateEventRepresentation 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).- 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
SerializedType getType()Returns the type and version of the data contained in this representation.- Returns:
- the type and version of the represented data
-
getData
SerializedObject<?> getData()Get the data of this representation. The type of the returned data should match that ofgetType().- Returns:
- the data representation of the object
-
getData
Get the data of this representation. The type of the returned data will be converted to the givenrequiredType.- Parameters:
requiredType- the type to convert to- Returns:
- the data representation of the object converted to the required type
-
getContentType
Returns the type of this representation'sdata.- Returns:
- The type of this representation's
data.
-
getMessageIdentifier
String getMessageIdentifier()Returns the identifier of the message wrapping the object to upcast.- Returns:
- the identifier of the message wrapping the object to upcast
-
getAggregateType
Returns 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.- Returns:
- the Type of the Aggregate to which the Event was applied, or an empty Optional if not applicable
-
getAggregateIdentifier
Returns 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.- Returns:
- the Identifier of the Aggregate to which the Event was applied, or an empty Optional if not applicable
-
getSequenceNumber
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 sequence number of the event in the aggregate, or an empty Optional if not applicable
-
getTrackingToken
Optional<TrackingToken> getTrackingToken()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.- Returns:
- the tracking token of the event, or an empty Optional if not applicable
-
getTimestamp
Instant getTimestamp()Returns the timestamp at which the event was first created. Will returnnullif the object being upcast- Returns:
- the timestamp at which the event was first created, if available
-
getMetaData
LazyDeserializingObject<MetaData> getMetaData()Returns 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.- Returns:
- the MetaData of the message wrapping the object to upcast, if available
-
canConvertDataTo
Checks if the data can be converted to the givenrequiredType.- 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
-