Package com.opencqrs.framework.upcaster
Interface EventUpcaster
- All Known Implementing Classes:
AbstractEventDataMarshallingEventUpcaster
,NoEventUpcaster
,TypeChangingEventUpcaster
public interface EventUpcaster
Interface to be implemented when
Event
s need to be migrated to a new representation, so-called upcasting.
This is required, as Event
s are immutable and thus need to be migrated on-the-fly.
Event upcasting is limited to Event.type()
and Event.data()
, represented by EventUpcaster.Result
.
This interface (and direct implementations) operate on the low-level Event
and hence may have to
use an additional EventDataMarshaller
if Event.data()
needs to be upcasted.
AbstractEventDataMarshallingEventUpcaster
may be inherited to gain access to EventData
based
upcasting.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
Captures upcastedEvent.type()
andEvent.data()
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines ifthis
upcaster is relevant for upcasting the givenEvent
.Upcasts the given event to a stream ofEventUpcaster.Result
s.
-
Method Details
-
canUpcast
Determines ifthis
upcaster is relevant for upcasting the givenEvent
. This method must be called prior toupcast(Event)
.- Parameters:
event
- the event that may need to be upcasted- Returns:
true
ifthis
can upcast the event,false
otherwise
-
upcast
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
- Parameters:
event
- the event to be upcasted- Returns:
- a stream of
EventUpcaster.Result
s carrying the upcastedEvent.type()
andEvent.data()
-