Class TransitionConditionPackager
TransitionConditionPackager serves as an adapter that unifies different transition implementations (JavaStateTransition and ActionDefinitionStateTransition) into a common executable format. This allows the transition execution engine to work with transitions regardless of whether they're defined in code or through declarative action definitions.
Key responsibilities:
- Type Adaptation: Converts StateTransition implementations to BooleanSupplier
- Action Execution: Orchestrates multi-step ActionDefinitions
- Success Evaluation: Determines overall success based on final step
- Sequential Processing: Executes action steps in order without conditional logic
ActionDefinition execution strategy:
- Execute all steps except the last one (side effects only)
- Execute the final step and evaluate its success
- Return the success of only the final step
- This assumes no conditional logic between steps
Design assumptions for ActionDefinitions:
- Steps are independent - no step depends on previous step's success
- All steps should execute regardless of individual failures
- Only the final step determines overall transition success
- Intermediate steps are for setup or side effects
Example ActionDefinition pattern:
Step 1: Click "Open Menu" button (setup action) Step 2: Click "Settings" option (navigation action) Step 3: Find "Settings Page" header (verification action) Only Step 3's success determines if transition succeeded
Integration with transition types:
- JavaStateTransition: Simply extracts existing BooleanSupplier
- ActionDefinitionStateTransition: Builds BooleanSupplier from action steps
- Future Types: Can be extended for new transition implementations
In the model-based approach, this packager enables seamless integration of different automation styles - from programmatic transitions written in Java to declarative workflows defined through visual tools. This flexibility allows teams to choose the most appropriate representation for each transition while maintaining a unified execution model.
- Since:
- 1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
getAsBoolean
(StateTransition transition) Executes a transition and returns its success status.toBooleanSupplier
(StateTransition transition) Converts a StateTransition to an executable BooleanSupplier.toBooleanSupplier
(TaskSequence actionDefinition) Converts an ActionDefinition into an executable BooleanSupplier.
-
Constructor Details
-
TransitionConditionPackager
-
-
Method Details
-
toBooleanSupplier
Converts a StateTransition to an executable BooleanSupplier.Handles polymorphic dispatch based on transition type:
- JavaStateTransition: Extracts existing function
- ActionDefinition-based: Builds function from steps
- Parameters:
transition
- StateTransition to convert- Returns:
- BooleanSupplier that executes the transition logic
- Throws:
IllegalArgumentException
- if transition type is unsupported
-
toBooleanSupplier
Converts an ActionDefinition into an executable BooleanSupplier.Creates a function that executes all action steps sequentially, with only the final step's success determining the overall result. This design supports multi-step transitions where intermediate steps perform setup or navigation actions, and the final step verifies arrival at the target state.
Execution behavior:
- All steps execute regardless of individual success/failure
- No conditional logic between steps
- Only the last step's success is evaluated
- Empty definitions return false
Example usage pattern:
ActionDefinition transition = new ActionDefinition(); transition.addStep(click("Menu")); // Setup - success ignored transition.addStep(click("Settings")); // Navigate - success ignored transition.addStep(find("SettingsPage")); // Verify - determines success
- Parameters:
actionDefinition
- Definition containing ordered action steps- Returns:
- BooleanSupplier that executes all steps and returns final step success
-
getAsBoolean
Executes a transition and returns its success status.Convenience method that converts and immediately executes a transition. Useful when you need a one-time execution without storing the supplier.
- Parameters:
transition
- StateTransition to execute- Returns:
- true if transition succeeded, false otherwise
- See Also:
-