Interface CommandHandler.ForInstanceAndCommand<I,C extends Command,R>

Type Parameters:
I - the generic type of the instance to be event sourced before handling the command
C - the command type
R - the command execution result type
All Superinterfaces:
CommandHandler<I,C,R>
Enclosing interface:
CommandHandler<I,C extends Command,R>
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 static non-sealed interface CommandHandler.ForInstanceAndCommand<I,C extends Command,R> extends CommandHandler<I,C,R>
FunctionalInterface to be implemented, if Command and event-sourced instance are needed for execution.
  • Method Details

    • handle

      R handle(I instance, C command, CommandEventPublisher<I> commandEventPublisher)
      Handles the given command on an event-sourced instance representing the current state (aka write model). The instance is sourced prior to calling this method based on CommandHandlerDefinition.sourcingMode() and a set of configured StateRebuildingHandlers. The given CommandEventPublisher enables the publication of new events upon successful command execution.
      Parameters:
      instance - the event-sourced instance the command is targeted at
      command - the command payload to be executed
      commandEventPublisher - a callback to publish new events
      Returns:
      a generic command execution result, may be null