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 Stream<? extends DomainEventMessage<?>> |
asStream(DomainEventStream domainEventStream)
Convert the given
domainEventStream to a regular java Stream of domain event messages. |
static <T> TrackedEventMessage<T> |
asTrackedEventMessage(EventMessage<T> eventMessage,
TrackingToken trackingToken)
|
static DomainEventStream |
upcastAndDeserializeDomainEvents(Stream<? extends DomainEventData<?>> eventEntryStream,
Serializer serializer,
EventUpcaster upcasterChain,
boolean skipUnknownTypes)
Upcasts and deserializes the given
eventEntryStream using the given serializer and
upcasterChain . |
static Stream<TrackedEventMessage<?>> |
upcastAndDeserializeTrackedEvents(Stream<? extends TrackedEventData<?>> eventEntryStream,
Serializer serializer,
EventUpcaster upcasterChain,
boolean skipUnknownTypes)
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 DomainEventStream upcastAndDeserializeDomainEvents(Stream<? extends DomainEventData<?>> eventEntryStream, Serializer serializer, EventUpcaster upcasterChain, boolean skipUnknownTypes)
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 withskipUnknownTypes
- whether unknown serialized types should be ignoredpublic static Stream<TrackedEventMessage<?>> upcastAndDeserializeTrackedEvents(Stream<? extends TrackedEventData<?>> eventEntryStream, Serializer serializer, EventUpcaster upcasterChain, boolean skipUnknownTypes)
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 withskipUnknownTypes
- whether unknown serialized types should be ignoredpublic static Stream<? extends DomainEventMessage<?>> asStream(DomainEventStream domainEventStream)
domainEventStream
to a regular java Stream
of domain event messages.domainEventStream
- the input DomainEventStream
Stream
after conversionCopyright © 2010–2018. All rights reserved.