Interface Transition

All Superinterfaces:
CanCopy<Transition>, HasId<TransitionId>, HasParent<Transition,Model<?,?>>, Model<Transition,TransitionId>, Validatable

public interface Transition extends Model<Transition,TransitionId>, HasParent<Transition,Model<?,?>>
Represents a transition between states in a workflow definition. Transition defines how a workflow can move from one state to another, including the conditions that must be met, the results that can occur, and the functions that are executed during the transition.

Transitions are the core mechanism for workflow state changes. They can be state-specific, common (available from multiple states), global (available from any state), or initial (used to start a workflow instance).

Transitions support:

  • Conditions - Determine when the transition is available
  • Results - Define the outcome and destination of the transition
  • Functions - Execute custom business logic before/after transition
  • Validators - Validate inputs before processing the transition
  • Auto-execution - Automatically execute when conditions are met
Since:
1.0
See Also:
  • Method Details

    • isAvailable

      boolean isAvailable(WorkflowExecutionContext context) throws WorkflowException
      Checks if this transition is available given the current attributes.
      Parameters:
      context - the execution context
      Returns:
      true if the transition is available, false otherwise
      Throws:
      WorkflowException - if there's an error checking availability
    • getResult

      Result<?> getResult(WorkflowExecutionContext context) throws WorkflowException
      Gets the result that should be executed for this transition given the current attributes.
      Parameters:
      context - the execution context
      Returns:
      the result to execute
      Throws:
      WorkflowException - if there's an error determining the result
    • getResult

      Result<?> getResult(WorkflowExecutionContext context, StateId stateId) throws WorkflowException
      Gets the result that should be executed for this transition given the current attributes and state.
      Parameters:
      context - the execution context
      stateId - the current state ID
      Returns:
      the result to execute
      Throws:
      WorkflowException - if there's an error determining the result
    • isAvailableForState

      boolean isAvailableForState(WorkflowExecutionContext context, StateId stateId) throws WorkflowException
      Checks if this transition is available for the specified state.
      Parameters:
      context - the execution context
      stateId - the state ID to check
      Returns:
      true if the transition is available for the state, false otherwise
      Throws:
      WorkflowException - if there's an error checking availability
    • executePreFunctions

      void executePreFunctions(WorkflowExecutionContext context) throws WorkflowException
      Executes all pre-functions for this transition.
      Parameters:
      context - the execution context
      Throws:
      WorkflowException - if there's an error executing the functions
    • executePostFunctions

      void executePostFunctions(WorkflowExecutionContext context) throws WorkflowException
      Executes all post-functions for this transition.
      Parameters:
      context - the execution context
      Throws:
      WorkflowException - if there's an error executing the functions
    • getGuards

      Conditions getGuards()
      Gets the conditions that determine when this transition is available.
      Returns:
      the conditions for this transition
    • asCommon

      Transition asCommon(Model<?,?> parent)
      Creates a common version of this transition that can be used from multiple states.
      Parameters:
      parent - the parent model element
      Returns:
      a new Transition instance configured as common
    • asGlobal

      Transition asGlobal(Model<?,?> parent)
      Creates a global version of this transition that can be used from any state.
      Parameters:
      parent - the parent model element
      Returns:
      a new Transition instance configured as global
    • asInitial

      Transition asInitial(Model<?,?> parent)
      Creates an initial version of this transition that can be used to start a workflow.
      Parameters:
      parent - the parent model element
      Returns:
      a new Transition instance configured as initial
    • getPropertyDifference

      Set<String> getPropertyDifference(Transition t2)
      Gets the property differences between this transition and another transition.
      Specified by:
      getPropertyDifference in interface Model<Transition,TransitionId>
      Parameters:
      t2 - the other transition to compare with
      Returns:
      a set of property names that differ between the transitions
    • getMetaAttributes

      Map<String,String> getMetaAttributes()
      Gets the meta attributes for this transition.
      Returns:
      a map of meta attributes
    • isCommon

      boolean isCommon()
      Checks if this transition is a common transition (available from multiple states).
      Returns:
      true if this is a common transition, false otherwise
    • isAutoExecute

      boolean isAutoExecute()
      Checks if this transition should be automatically executed when conditions are met.
      Returns:
      true if this transition should auto-execute, false otherwise
    • getConditionalResults

      List<ConditionalResult> getConditionalResults()
      Gets all conditional results for this transition.
      Returns:
      a list containing all conditional results
    • getDefaultResult

      DefaultResult getDefaultResult()
      Gets the default result for this transition.
      Returns:
      the default result
    • getPreFunctions

      List<Function> getPreFunctions()
      Gets all pre-functions for this transition.
      Returns:
      a list containing all pre-functions
    • getPostFunctions

      List<Function> getPostFunctions()
      Gets all post-functions for this transition.
      Returns:
      a list containing all post-functions
    • getValidators

      List<Validator> getValidators()
      Gets all validators for this transition.
      Returns:
      a list containing all validators
    • verifyInputs

      void verifyInputs(WorkflowExecutionContext context) throws WorkflowException
      Verifies the inputs for this transition against all validators.
      Parameters:
      context - the execution context
      Throws:
      WorkflowException - if validation fails
    • toBuilder

      Creates a new BuildableTransitionBuilder initialized with the current transition definition. This method allows for easy modification of existing transition definitions by providing a builder that starts with the current state of the transition.

      The returned builder can be used to modify the transition definition by adding, removing, or modifying results, conditions, functions, validators, and other transition elements. After making the desired changes, call BuildableTransitionBuilder.build() to create a new Transition instance.

      This is particularly useful for:

      • Creating variations of existing transitions
      • Implementing transition versioning
      • Making incremental changes to transition definitions
      Returns:
      a new BuildableTransitionBuilder initialized with this transition's current state
      See Also: