T
- the required type of the serialized data. If the data is not of this type the representation uses a Converter
to convert to the required type.public class UpcastedEventRepresentation<T> extends Object implements IntermediateEventRepresentation
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.Constructor and Description |
---|
UpcastedEventRepresentation(SerializedType outputType,
IntermediateEventRepresentation source,
Function<T,T> upcastFunction,
Function<MetaData,MetaData> metaDataUpcastFunction,
Class<T> requiredType,
Converter converter)
Initializes an
UpcastedEventRepresentation from source data and given upcast functions for payload and
metadata. |
Modifier and Type | Method and Description |
---|---|
boolean |
canConvertDataTo(Class<?> requiredType)
Checks if the data can be converted to the given
requiredType . |
Optional<String> |
getAggregateIdentifier()
Returns the Identifier of the Aggregate to which the Event owning the object to upcast, was applied.
|
Optional<String> |
getAggregateType()
Returns the Type of the Aggregate to which the Event owning the object to upcast, was applied.
|
Class<?> |
getContentType()
Returns the type of this representation's
data . |
SerializedObject<T> |
getData()
Get the data of this representation.
|
<D> SerializedObject<D> |
getData(Class<D> requiredType)
Get the data of this representation.
|
String |
getMessageIdentifier()
Returns the identifier of the message wrapping the object to upcast.
|
LazyDeserializingObject<MetaData> |
getMetaData()
Returns the meta data of the message wrapping the object being upcast.
|
Optional<Long> |
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.
|
Instant |
getTimestamp()
Returns the timestamp at which the event was first created.
|
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.
|
SerializedType |
getType()
Returns the type and version of the data contained in this representation.
|
<S> IntermediateEventRepresentation |
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).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
upcastPayload
public UpcastedEventRepresentation(SerializedType outputType, IntermediateEventRepresentation source, Function<T,T> upcastFunction, Function<MetaData,MetaData> metaDataUpcastFunction, Class<T> requiredType, Converter converter)
UpcastedEventRepresentation
from source data and given upcast functions for payload and
metadata. The given converter
is used to convert to the serialized data format required by the upcast
functions.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 requiredpublic <S> IntermediateEventRepresentation upcast(SerializedType outputType, Class<S> expectedRepresentationType, Function<S,S> upcastFunction, Function<MetaData,MetaData> metaDataUpcastFunction)
IntermediateEventRepresentation
upcast
in interface IntermediateEventRepresentation
S
- The expected payload type before and after upcastingoutputType
- 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 metadatapublic SerializedType getType()
IntermediateEventRepresentation
getType
in interface IntermediateEventRepresentation
public SerializedObject<T> getData()
IntermediateEventRepresentation
IntermediateEventRepresentation.getType()
.getData
in interface IntermediateEventRepresentation
public <D> SerializedObject<D> getData(Class<D> requiredType)
IntermediateEventRepresentation
requiredType
.getData
in interface IntermediateEventRepresentation
requiredType
- the type to convert topublic Class<?> getContentType()
IntermediateEventRepresentation
data
.getContentType
in interface IntermediateEventRepresentation
data
.public String getMessageIdentifier()
IntermediateEventRepresentation
getMessageIdentifier
in interface IntermediateEventRepresentation
public Optional<String> getAggregateType()
IntermediateEventRepresentation
getAggregateType
in interface IntermediateEventRepresentation
public Optional<String> getAggregateIdentifier()
IntermediateEventRepresentation
getAggregateIdentifier
in interface IntermediateEventRepresentation
public Optional<Long> getSequenceNumber()
IntermediateEventRepresentation
getSequenceNumber
in interface IntermediateEventRepresentation
public Optional<TrackingToken> getTrackingToken()
IntermediateEventRepresentation
getTrackingToken
in interface IntermediateEventRepresentation
public Instant getTimestamp()
IntermediateEventRepresentation
null
if the object being upcastgetTimestamp
in interface IntermediateEventRepresentation
public LazyDeserializingObject<MetaData> getMetaData()
IntermediateEventRepresentation
null
.getMetaData
in interface IntermediateEventRepresentation
public boolean canConvertDataTo(Class<?> requiredType)
IntermediateEventRepresentation
requiredType
.canConvertDataTo
in interface IntermediateEventRepresentation
requiredType
- the type to validate if the contained data can be converted to.Copyright © 2010–2023. All rights reserved.