Package com.opencqrs.framework.upcaster
Class AbstractEventDataMarshallingEventUpcaster
java.lang.Object
com.opencqrs.framework.upcaster.AbstractEventDataMarshallingEventUpcaster
- All Implemented Interfaces:
EventUpcaster
public abstract class AbstractEventDataMarshallingEventUpcaster
extends Object
implements EventUpcaster
Template implementation of
EventUpcaster
that uses a delegate EventDataMarshaller
to allow subclasses
to upcast EventData.metaData()
and EventData.payload()
as pre-extracted JSON-like Map
s.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Captures upcastedEvent.type()
, meta-data, and payload.Nested classes/interfaces inherited from interface com.opencqrs.framework.upcaster.EventUpcaster
EventUpcaster.Result
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractEventDataMarshallingEventUpcaster
(EventDataMarshaller eventDataMarshaller) Constructor for implementations ofthis
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Stream
<AbstractEventDataMarshallingEventUpcaster.MetaDataAndPayloadResult> Template method to be implemented by subclasses to upcast the given meta-data and payload.final Stream
<EventUpcaster.Result> Upcasts the given event to a stream ofEventUpcaster.Result
s.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.opencqrs.framework.upcaster.EventUpcaster
canUpcast
-
Constructor Details
-
AbstractEventDataMarshallingEventUpcaster
Constructor for implementations ofthis
.- Parameters:
eventDataMarshaller
- the marshaller used to extractEventData
fromEvent.data()
-
-
Method Details
-
upcast
Description copied from interface:EventUpcaster
Upcasts the given event to a stream ofEventUpcaster.Result
s. This allows implementations to:- effectively drop an event by returning an empty stream
- upcast an event to one new event by returning a single element stream
- effectively split up an event by returning a multi element stream
- Specified by:
upcast
in interfaceEventUpcaster
- Parameters:
event
- the event to be upcasted- Returns:
- a stream of
EventUpcaster.Result
s carrying the upcastedEvent.type()
andEvent.data()
-
doUpcast
protected abstract Stream<AbstractEventDataMarshallingEventUpcaster.MetaDataAndPayloadResult> doUpcast(Event event, Map<String, ?> metaData, Map<String, ?> payload) Template method to be implemented by subclasses to upcast the given meta-data and payload.- Parameters:
event
- the event from which meta-data and payload have been extractedmetaData
- the meta-datapayload
- the payload as JSON-like map- Returns:
- a stream of
AbstractEventDataMarshallingEventUpcaster.MetaDataAndPayloadResult
carrying the upcasted representations - See Also:
-