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:
  • Method Details

    • canUpcast

      boolean canUpcast(Event event)
      Determines if this upcaster is relevant for upcasting the given Event. This method must be called prior to upcast(Event).
      Parameters:
      event - the event that may need to be upcasted
      Returns:
      true if this can upcast the event, false otherwise
    • upcast

      Upcasts the given event to a stream of EventUpcaster.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 upcasted Event.type() and Event.data()