Class TypeChangingEventUpcaster

java.lang.Object
com.opencqrs.framework.upcaster.TypeChangingEventUpcaster
All Implemented Interfaces:
EventUpcaster

public class TypeChangingEventUpcaster extends Object implements EventUpcaster
EventUpcaster implementation that changes the Event.type() to a new type if it matches the configured source type.
  • Constructor Details

    • TypeChangingEventUpcaster

      public TypeChangingEventUpcaster(String sourceType, String targetType)
  • Method Details

    • canUpcast

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

      public Stream<EventUpcaster.Result> upcast(Event event)
      Description copied from interface: EventUpcaster
      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
      Specified by:
      upcast in interface EventUpcaster
      Parameters:
      event - the event to be upcasted
      Returns:
      a stream of EventUpcaster.Results carrying the upcasted Event.type() and Event.data()