Annotation Type AssertLegal


@Target({METHOD,FIELD,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface AssertLegal
Annotation to be placed on methods in commands or queries. After an aggregate is loaded and a AggregateRoot is returned you can pass the command or query to the Entity.assertLegal(java.lang.Object) method to assert whether or not the command or query is allowed given the state of the model.

Annotated methods should contain at least one parameter. The first parameter is reserved for the Model's entity (as obtained via Entity.get()).

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Determines if the legality check should be performed immediately (the default), or when the current handler is done, i.e.
    int
    Determines the order of assertions if there are multiple annotated methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
  • Field Details

  • Element Details

    • priority

      int priority
      Determines the order of assertions if there are multiple annotated methods. A method with higher priority will be invoked before methods with a lower priority. Use HIGHEST_PRIORITY to ensure that the check is performed first.
      Default:
      0
    • afterHandler

      boolean afterHandler
      Determines if the legality check should be performed immediately (the default), or when the current handler is done, i.e. just before the aggregate updates are committed.
      Default:
      false