Interface ConflictResolver

All Known Implementing Classes:
DefaultConflictResolver, NoConflictResolver

public interface ConflictResolver
Interface describing an object that is capable of detecting conflicts between changes to be applied to an aggregate, and unseen changes made to the aggregate. If any such conflicts are detected, an instance of ConflictingModificationException (or subtype) is thrown.
Author:
Rene de Waele, Allard Buijze
  • Method Details

    • detectConflicts

      default <T extends Exception> void detectConflicts(Predicate<List<DomainEventMessage<?>>> predicate, ConflictExceptionSupplier<T> exceptionSupplier) throws T
      Resolve conflicts between unseen changes made to the aggregate and new changes that are about to be made.

      Conflicts are detected using the given predicate. If the Predicate.test(Object) method returns true a conflict is registered. If a conflict is registered an instance of ConflictingModificationException (or subtype) is thrown immediately. The cause of the exception is supplied by the given causeSupplier (supplying a null cause is allowed).

      Parameters:
      predicate - test for conflicting unseen changes. Returns true if there is a conflict.
      exceptionSupplier - exception to throw when a conflict is detected
      Throws:
      T - The type of exception to throw when conflicts are detected
    • detectConflicts

      default void detectConflicts(Predicate<List<DomainEventMessage<?>>> predicate)
      Resolve conflicts between changes to be applied to the aggregate and unseen changes made to the aggregate.

      Conflicts are detected using the given predicate. If the Predicate.test(Object) method returns true a conflict is registered. If a conflict is registered an instance of ConflictingModificationException (or subtype) without cause is thrown immediately.

      Parameters:
      predicate - test for conflicting unseen changes. Returns true if there is a conflict.
    • detectConflicts

      <T extends Exception> void detectConflicts(Predicate<List<DomainEventMessage<?>>> predicate, ContextAwareConflictExceptionSupplier<T> exceptionSupplier) throws T
      Resolve conflicts between unseen changes made to the aggregate and new changes that are about to be made.

      Conflicts are detected using the given predicate. If the Predicate.test(Object) method returns true a conflict is registered. If a conflict is registered an instance of ConflictingModificationException (or subtype) is thrown immediately. The cause of the exception is supplied by the given causeSupplier (supplying a null cause is allowed).

      Parameters:
      predicate - test for conflicting unseen changes. Returns true if there is a conflict.
      exceptionSupplier - exception to throw when a conflict is detected
      Throws:
      T - The type of exception to throw when conflicts are detected