Class StateTransition
java.lang.Object
org.springframework.batch.core.job.flow.support.StateTransition
Value object representing a potential transition from one
State to another. The
originating State name and the next State to execute are linked by a pattern
for the exit code of an execution of the originating
State.- Since:
- 2.0
- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Method Summary
Modifier and TypeMethodDescriptionstatic StateTransitioncreateEndStateTransition(State state) Create a new end stateStateTransitionspecification.static StateTransitioncreateEndStateTransition(State state, String pattern) Create a new end stateStateTransitionspecification.static StateTransitioncreateStateTransition(State state, String next) Create a new stateStateTransitionspecification with a wildcard pattern that matches all outcomes.static StateTransitioncreateStateTransition(State state, String pattern, String next) Create a newStateTransitionspecification from oneStateto another (by name).getNext()Public getter for the next State name.getState()Public getter for the State.booleanisEnd()Check for a special next State signalling the end of a job.booleanCheck if the provided status matches the pattern, signalling that the next State should be executed.static StateTransitionswitchOriginAndDestination(StateTransition stateTransition, State state, String next) Convenience method to switch the origin and destination of a transition, creating a new instance.toString()
-
Method Details
-
getPattern
- Returns:
- the pattern the
ExitStatus.getExitCode()will be compared against.
-
createEndStateTransition
Create a new end stateStateTransitionspecification. This transition explicitly goes unconditionally to an end state (i.e. no more executions).- Parameters:
state- theStateused to generate the outcome for this transition- Returns:
StateTransitionthat was created.
-
createEndStateTransition
Create a new end stateStateTransitionspecification. This transition explicitly goes to an end state (i.e. no more processing) if the outcome matches the pattern.- Parameters:
state- theStateused to generate the outcome for this transitionpattern- the pattern to match in the exit status of theState- Returns:
StateTransitionthat was created.
-
switchOriginAndDestination
public static StateTransition switchOriginAndDestination(StateTransition stateTransition, State state, String next) Convenience method to switch the origin and destination of a transition, creating a new instance.- Parameters:
stateTransition- an existing state transitionstate- the new state for the originnext- the new name for the destination- Returns:
StateTransitionthat was created.
-
createStateTransition
Create a new stateStateTransitionspecification with a wildcard pattern that matches all outcomes.- Parameters:
state- theStateused to generate the outcome for this transitionnext- the name of the nextStateto execute- Returns:
StateTransitionthat was created.
-
createStateTransition
public static StateTransition createStateTransition(State state, @Nullable String pattern, @Nullable String next) Create a newStateTransitionspecification from oneStateto another (by name).- Parameters:
state- theStateused to generate the outcome for this transitionpattern- the pattern to match in the exit status of theState(can benull)next- the name of the nextStateto execute (can benull)- Returns:
StateTransitionthat was created.
-
getState
Public getter for the State.- Returns:
- the State
-
getNext
Public getter for the next State name.- Returns:
- the next
-
matches
Check if the provided status matches the pattern, signalling that the next State should be executed.- Parameters:
status- the status to compare- Returns:
- true if the pattern matches this status
-
isEnd
public boolean isEnd()Check for a special next State signalling the end of a job.- Returns:
- true if this transition goes nowhere (there is no next)
-
toString
-