Interface SourcingCondition

All Superinterfaces:
EventsCondition

public sealed interface SourcingCondition extends EventsCondition
Interface describing the condition to source events from an Event Store.

The condition has a mandatory EventsCondition.criteria() used to retrieve the exact sequence of events to source the model(s). The start() operation defines the start point when sourcing events that the EventStoreTransaction is interested in.

Since:
5.0.0
Author:
Michal Negacz, Milan Savić, Marco Amann, Sara Pellegrini, Steven van Beelen
  • Method Details

    • conditionFor

      static SourcingCondition conditionFor(@Nonnull EventCriteria criteria)
      Construct a SourcingCondition used to source a model based on the given criteria.
      Parameters:
      criteria - The EventCriteria used as the EventsCondition.criteria().
      Returns:
      A SourcingCondition that will retrieve an event sequence matching the given criteria.
    • conditionFor

      static SourcingCondition conditionFor(@Nonnull Position start, @Nonnull EventCriteria criteria)
      Construct a SourcingCondition used to source a model based on the given criteria.

      Will start the sequence at the given start value.

      Parameters:
      start - The start position in the event sequence to retrieve of the model to source.
      criteria - The EventCriteria used as the EventsCondition.criteria().
      Returns:
      A SourcingCondition that will retrieve an event sequence matching the given criteria, starting at the given start.
    • start

      @Nonnull default Position start()
      The start position in the event sequence to source. Defaults to -1L to ensure we start at the beginning of the sequence's stream complying to the EventsCondition.criteria().
      Returns:
      The start position in the event sequence to source, never null.
    • or

      Merges this SourcingCondition with the given other SourcingCondition, by combining their search criteria and starting points.

      Warning: If the starting points don't overlap or connect properly, the merged condition might return some events that neither of the original conditions would have returned on their own.

      Usually, the earlier starting point (minimum start value) will be used in the final merged condition.

      Parameters:
      other - The SourcingCondition to combine with this SourcingCondition.
      Returns:
      A combined SourcingCondition based on this SourcingCondition and the given other.