Package com.opencqrs.framework.upcaster
Interface EventUpcaster
- All Known Implementing Classes:
AbstractEventDataMarshallingEventUpcaster,NoEventUpcaster,TypeChangingEventUpcaster
public interface EventUpcaster
Interface to be implemented when
Events need to be migrated to a new representation, so-called upcasting.
This is required, as Events 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 recordCaptures upcastedEvent.type()andEvent.data(). -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines ifthisupcaster is relevant for upcasting the givenEvent.Upcasts the given event to a stream ofEventUpcaster.Results.
-
Method Details
-
canUpcast
Determines ifthisupcaster 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:
trueifthiscan upcast the event,falseotherwise
-
upcast
Upcasts the given event to a stream ofEventUpcaster.Results. 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.Results carrying the upcastedEvent.type()andEvent.data()
-