Interface State

All Superinterfaces:
CanCopy<State>, HasId<StateId>, HasParent<State,WorkflowDefinition>, Model<State,StateId>, Validatable

public interface State extends Model<State,StateId>, HasParent<State,WorkflowDefinition>
Represents a state in a workflow definition. State is a fundamental component of workflows that defines a specific stage or condition in a business process.

States contain transitions that define how the workflow can move to other states, capabilities that define what actions are available in the state, and functions that are executed when entering or leaving the state.

States can have:

  • Transitions - Ways to move to other states
  • Capabilities - Information associated with the state
  • Pre-functions - Functions executed when entering the state
  • Post-functions - Functions executed when leaving the state
  • Common transitions - Transitions available from multiple states
Since:
1.0
See Also:
  • Method Details

    • getTransition

      Optional<Transition> getTransition(TransitionId id)
      Gets a transition by its ID.
      Parameters:
      id - the ID of the transition to retrieve
      Returns:
      an Optional containing the transition if found
    • resultsInJoin

      boolean resultsInJoin(JoinId join)
      Checks if this state results in the specified join.
      Parameters:
      join - the join to check
      Returns:
      true if this state results in the join, false otherwise
    • executePreFunctions

      void executePreFunctions(WorkflowExecutionContext context) throws WorkflowException
      Executes all pre-functions for this state with the given attributes.
      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 state with the given attributes.
      Parameters:
      context - the execution context
      Throws:
      WorkflowException - if there's an error executing the functions
    • getTransitions

      List<Transition> getTransitions()
      Gets all transitions available from this state.
      Returns:
      a list containing all transitions
    • getCommonTransitionIds

      Iterable<TransitionId> getCommonTransitionIds()
      Gets all common transition IDs available from this state.
      Returns:
      an iterable of common transition IDs
    • getMetaAttributes

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

      List<Capability> getCapabilities()
      Gets all capabilities available in this state.
      Returns:
      a list containing all capabilities
    • getPostFunctions

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

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

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

      The returned builder can be used to modify the state definition by adding, removing, or modifying transitions, capabilities, functions, and other state elements. After making the desired changes, call BuildableStateBuilder.build() to create a new State instance.

      This is particularly useful for:

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