Record Class CommandHandlerDefinition<I,C extends Command,R>

java.lang.Object
java.lang.Record
com.opencqrs.framework.command.CommandHandlerDefinition<I,C,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
Record Components:
instanceClass - instance type used for state rebuilding
commandClass - command type to be executed
handler - command handler to be executed
sourcingMode - the event-sourcing mode for the CommandHandler

public record CommandHandlerDefinition<I,C extends Command,R>(Class<I> instanceClass, Class<C extends Command> commandClass, CommandHandler<I,C extends Command,R> handler, SourcingMode sourcingMode) extends Record
CommandHandler definition suitable for being processed by the CommandRouter.
  • Constructor Details

    • CommandHandlerDefinition

      public CommandHandlerDefinition(Class<I> instanceClazz, Class<C> commandClazz, CommandHandler<I,C,R> commandHandler)
      Convenience constructor using SourcingMode.RECURSIVE.
      Parameters:
      instanceClazz - instance type used for state rebuilding
      commandClazz - command type to be executed
      commandHandler - command handler to be executed
    • CommandHandlerDefinition

      public CommandHandlerDefinition(Class<I> instanceClass, Class<C> commandClass, CommandHandler<I,C,R> handler, SourcingMode sourcingMode)
      Creates an instance of a CommandHandlerDefinition record class.
      Parameters:
      instanceClass - the value for the instanceClass record component
      commandClass - the value for the commandClass record component
      handler - the value for the handler record component
      sourcingMode - the value for the sourcingMode record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • instanceClass

      public Class<I> instanceClass()
      Returns the value of the instanceClass record component.
      Returns:
      the value of the instanceClass record component
    • commandClass

      public Class<C> commandClass()
      Returns the value of the commandClass record component.
      Returns:
      the value of the commandClass record component
    • handler

      public CommandHandler<I,C,R> handler()
      Returns the value of the handler record component.
      Returns:
      the value of the handler record component
    • sourcingMode

      public SourcingMode sourcingMode()
      Returns the value of the sourcingMode record component.
      Returns:
      the value of the sourcingMode record component