Annotation Interface State


@Target(TYPE) @Retention(RUNTIME) @Documented @Component @DependsOn("imageLoadingInitializer") public @interface State
Annotation for Brobot states. This annotation marks a class as a Brobot state and includes @Component for Spring component scanning.

Classes annotated with @State should also include: - @Getter from Lombok for generating getters - @Slf4j from Lombok for logging

Hidden States: When a state overlays another (e.g., a modal dialog opening over a page), the framework automatically tracks the covered state as "hidden". This enables dynamic transitions using PreviousState.class to return to whatever was covered. States don't need to explicitly define their hidden states - this is managed automatically by the framework based on state activation patterns.

Usage:

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional description of the state's purpose.
    boolean
    Indicates whether this state is an initial state.
    Optional name for the state.
    int
    Path-finding cost for reaching this state.
    int
    Priority for initial state selection (higher values = higher priority).
    Spring profiles where this state should be considered initial.
  • Element Details

    • initial

      boolean initial
      Indicates whether this state is an initial state. Initial states are automatically registered with the StateTransitionsJointTable as starting points for the state machine.
      Returns:
      true if this is an initial state, false otherwise
      Default:
      false
    • name

      String name
      Optional name for the state. If not specified, the simple class name (without "State" suffix if present) will be used.
      Returns:
      the state name
      Default:
      ""
    • description

      String description
      Optional description of the state's purpose. This can be used for documentation and debugging.
      Returns:
      the state description
      Default:
      ""
    • priority

      int priority
      Priority for initial state selection (higher values = higher priority). Used when multiple initial states are defined to influence selection probability. Default is 100 for equal probability among all initial states. Only applies when initial = true.
      Returns:
      priority value for this initial state
      Since:
      1.2.0
      Default:
      100
    • profiles

      String[] profiles
      Spring profiles where this state should be considered initial. Empty array means the state is initial in all profiles. Only applies when initial = true.

      Example: @State(initial = true, profiles = {"test", "development"})

      Returns:
      array of profile names where this state is initial
      Since:
      1.2.0
      Default:
      {}
    • pathCost

      int pathCost
      Path-finding cost for reaching this state. The total cost of a path is the sum of all state costs and transition costs in that path. Lower costs are preferred when multiple paths exist. Default is 1.

      Example uses:

      • 0 - Free state (no cost to be in this state)
      • 1 - Normal state (default)
      • 5 - Slightly expensive state (e.g., requires loading)
      • 10+ - Expensive state to reach (e.g., error recovery states)
      Returns:
      the path cost for being in this state
      Since:
      1.3.0
      Default:
      1