Package com.yworkflow.definition.model
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 Summary
Modifier and TypeMethodDescriptionCreates a common version of this transition that can be used from multiple states.Creates a global version of this transition that can be used from any state.Creates an initial version of this transition that can be used to start a workflow.voidExecutes all post-functions for this transition.voidExecutes all pre-functions for this transition.Gets all conditional results for this transition.Gets the default result for this transition.Gets the conditions that determine when this transition is available.Gets the meta attributes for this transition.Gets all post-functions for this transition.Gets all pre-functions for this transition.Gets the property differences between this transition and another transition.Result<?>getResult(WorkflowExecutionContext context) Gets the result that should be executed for this transition given the current attributes.Result<?>getResult(WorkflowExecutionContext context, StateId stateId) Gets the result that should be executed for this transition given the current attributes and state.Gets all validators for this transition.booleanChecks if this transition should be automatically executed when conditions are met.booleanisAvailable(WorkflowExecutionContext context) Checks if this transition is available given the current attributes.booleanisAvailableForState(WorkflowExecutionContext context, StateId stateId) Checks if this transition is available for the specified state.booleanisCommon()Checks if this transition is a common transition (available from multiple states).Creates a new BuildableTransitionBuilder initialized with the current transition definition.voidverifyInputs(WorkflowExecutionContext context) Verifies the inputs for this transition against all validators.Methods inherited from interface com.yworkflow.definition.model.base.HasParent
withParentMethods inherited from interface com.yworkflow.definition.model.base.Model
getExtensions, getParent, getPropertiesMethods inherited from interface com.yworkflow.definition.model.validation.Validatable
validate
-
Method Details
-
isAvailable
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
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
Gets the result that should be executed for this transition given the current attributes and state.- Parameters:
context- the execution contextstateId- 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 contextstateId- 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
Executes all pre-functions for this transition.- Parameters:
context- the execution context- Throws:
WorkflowException- if there's an error executing the functions
-
executePostFunctions
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
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
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
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
Gets the property differences between this transition and another transition.- Specified by:
getPropertyDifferencein interfaceModel<Transition,TransitionId> - Parameters:
t2- the other transition to compare with- Returns:
- a set of property names that differ between the transitions
-
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
Gets all pre-functions for this transition.- Returns:
- a list containing all pre-functions
-
getPostFunctions
Gets all post-functions for this transition.- Returns:
- a list containing all post-functions
-
getValidators
Gets all validators for this transition.- Returns:
- a list containing all validators
-
verifyInputs
Verifies the inputs for this transition against all validators.- Parameters:
context- the execution context- Throws:
WorkflowException- if validation fails
-
toBuilder
BuildableTransitionBuilder 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:
-