Class TransitionExecutor

java.lang.Object
io.github.jspinak.brobot.navigation.transition.TransitionExecutor

@Component public class TransitionExecutor extends Object
Orchestrates complex state transitions in the Brobot framework.

TransitionExecutor is the central execution engine for state transitions, managing the intricate process of moving from one GUI state to another. It coordinates all aspects of a transition including action execution, state activation/deactivation, hidden state management, and cascading transitions.

Transition anatomy:

  • FromTransition: Actions and state changes originating from the source state
  • ToTransition: Recognition and finalization of the target state
  • Cascading Transitions: Additional states activated as side effects
  • Exit Transitions: States deactivated during the transition

Execution phases:

  1. Validation: Verify source state is active and transition exists
  2. FromTransition: Execute actions to leave source state
  3. State Discovery: Determine all states to activate (including cascades)
  4. ToTransitions: Execute recognition for each target state
  5. Hidden States: Update hidden state relationships
  6. Exit States: Deactivate states marked for exit
  7. Verification: Confirm target state is now active

Key features:

  • Cascading Support: States can trigger activation of additional states
  • Hidden State Handling: Manages overlay relationships between states
  • Probability Updates: Adjusts state existence probabilities for mock mode
  • Cycle Prevention: Avoids infinite loops in mutually-activating states
  • Partial Success: Core transition can succeed even if cascades fail

Complex transition scenarios:

  • Multi-State Activation: Opening a dialog that shows multiple panels
  • State Replacement: Tab switching where one state replaces another
  • Overlay Management: Modal dialogs that hide but don't close underlying states
  • Back Navigation: Returning to previously hidden states

Design philosophy:

  • Transitions are atomic - either the core transition succeeds or fails
  • Side effects (cascading transitions) don't affect core success
  • Already-active states are not re-activated (prevents cycles)
  • Hidden states are preserved for back navigation

In the model-based approach, TransitionExecutor embodies the framework's understanding of how GUI state changes occur. Rather than simple page-to-page navigation, it models the complex reality of modern GUIs where actions can trigger multiple state changes, overlays, and cascading effects.

Since:
1.0
See Also:
  • Constructor Details

  • Method Details

    • go

      public boolean go(Long fromStateId, Long toStateId)
      Executes a complete state transition from source to target state.

      This is the primary entry point for state transitions, handling all aspects of moving from one state to another including action execution, state activation/deactivation, and cascade management.

      Important notes:

      • Source state must be currently active for transition to proceed
      • PREVIOUS state references are resolved before reaching this method
      • Success is determined by core transition, not cascading effects
      • Logs success/failure to Report for debugging and monitoring

      Side effects:

      • Updates StateMemory with new active/inactive states
      • Modifies state probabilities for mock mode
      • Updates hidden state relationships
      • Increments transition success counters
      Parameters:
      fromStateId - ID of the source state (must be active)
      toStateId - ID of the target state to transition to
      Returns:
      true if the transition succeeded, false otherwise
      See Also:
      • doTransitions(Long, Long)