public abstract class EventUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> DomainEventMessage<T> |
asDomainEventMessage(EventMessage<T> eventMessage)
Convert a plain
EventMessage to a DomainEventMessage . |
static <T> TrackedEventMessage<T> |
asTrackedEventMessage(EventMessage<T> eventMessage,
TrackingToken trackingToken)
|
static Stream<TrackedEventMessage<?>> |
upcastAndDeserializeTrackedEvents(Stream<? extends TrackedEventData<?>> eventEntryStream,
Serializer serializer,
EventUpcaster upcasterChain)
Upcasts and deserializes the given
eventEntryStream using the given serializer and
upcasterChain . |
public static <T> TrackedEventMessage<T> asTrackedEventMessage(EventMessage<T> eventMessage, TrackingToken trackingToken)
EventMessage
to a TrackedEventMessage
using the given trackingToken
. If the
event is a DomainEventMessage
the message will be converted to a GenericTrackedDomainEventMessage
, otherwise a GenericTrackedEventMessage
is returned.T
- the payload type of the eventeventMessage
- the message to converttrackingToken
- the tracking token to use for the resulting messagepublic static <T> DomainEventMessage<T> asDomainEventMessage(EventMessage<T> eventMessage)
EventMessage
to a DomainEventMessage
. If the message already is a DomainEventMessage
it will be returned as is. Otherwise a new GenericDomainEventMessage
is made with
null
type, aggegrateIdentifier equal to messageIdentifier and sequence number of 0L.T
- The type of payload in the messageeventMessage
- the input event messagepublic static Stream<TrackedEventMessage<?>> upcastAndDeserializeTrackedEvents(Stream<? extends TrackedEventData<?>> eventEntryStream, Serializer serializer, EventUpcaster upcasterChain)
eventEntryStream
using the given serializer
and
upcasterChain
.
The list of events returned contains lazy deserializing events for optimization purposes. Events represented with
unknown classes are ignored if skipUnknownTypes
is true
eventEntryStream
- the stream of entries containing the data of the serialized eventserializer
- the serializer to deserialize the event withupcasterChain
- the chain containing the upcasters to upcast the events withCopyright © 2010–2020. All rights reserved.