Interface SnapshotFilter

All Superinterfaces:
Predicate<DomainEventData<?>>
All Known Implementing Classes:
RevisionSnapshotFilter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SnapshotFilter extends Predicate<DomainEventData<?>>
Functional interface defining an allow(DomainEventData) method to take snapshot data into account when loading an aggregate. When providing an instance of this, take the following into account:
  1. Only return false if the snapshot data belongs to the corresponding aggregate and it does no conform to the desired format.
  2. Return true if the snapshot data belongs to the corresponding aggregate and conforms to the desired format.
  3. Return true if the snapshot data does not correspond to the desired aggregate.

Whether the DomainEventData corresponds to the right aggregate and is of the desired format, is dependent on the Snapshotter instance being used. By default, the AggregateSnapshotter instances would be used.

In such a default set up, DomainEventData corresponding to the right aggregate means that the DomainEventData.getType() matches the aggregate's type. If DomainEventData is of the desired format should be based on the EventData.getPayload(), which contains the entire aggregate state.

Since:
4.4
Author:
Steven van Beelen
  • Method Details

    • allow

      default boolean allow(DomainEventData<?> snapshotData)
      Function applied to filter out snapshot data in the form of a DomainEventData. Return true if the data should be kept and false if it should be dropped.
      Parameters:
      snapshotData - the snapshot data to verify for filtering
      Returns:
      true if the data should be kept and false if it should be dropped
    • combine

      default SnapshotFilter combine(SnapshotFilter other)
      Combines this SnapshotFilter with the give other filter in an "AND" operation, effectively validating whether both return true on a allow(DomainEventData) call of each.
      Parameters:
      other - another SnapshotFilter instance to combine with this filter in an "AND" operation
      Returns:
      a new SnapshotFilter combining the this and other filters in an "AND" operation
    • allowAll

      static SnapshotFilter allowAll()
      A SnapshotFilter implementation which allows all snapshots.
      Returns:
      SnapshotFilter implementation which allows all snapshots
    • rejectAll

      static SnapshotFilter rejectAll()
      A SnapshotFilter implementation which rejects all snapshots.
      Returns:
      a SnapshotFilter implementation which rejects all snapshots