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 StateTransition
createEndStateTransition
(State state) Create a new end stateStateTransition
specification.static StateTransition
createEndStateTransition
(State state, String pattern) Create a new end stateStateTransition
specification.static StateTransition
createStateTransition
(State state, String next) Create a new stateStateTransition
specification with a wildcard pattern that matches all outcomes.static StateTransition
createStateTransition
(State state, String pattern, String next) Create a newStateTransition
specification from oneState
to another (by name).getNext()
Public getter for the next State name.getState()
Public getter for the State.boolean
isEnd()
Check for a special next State signalling the end of a job.boolean
Check if the provided status matches the pattern, signalling that the next State should be executed.static StateTransition
switchOriginAndDestination
(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 stateStateTransition
specification. This transition explicitly goes unconditionally to an end state (i.e. no more executions).- Parameters:
state
- theState
used to generate the outcome for this transition- Returns:
StateTransition
that was created.
-
createEndStateTransition
Create a new end stateStateTransition
specification. This transition explicitly goes to an end state (i.e. no more processing) if the outcome matches the pattern.- Parameters:
state
- theState
used to generate the outcome for this transitionpattern
- the pattern to match in the exit status of theState
- Returns:
StateTransition
that 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:
StateTransition
that was created.
-
createStateTransition
Create a new stateStateTransition
specification with a wildcard pattern that matches all outcomes.- Parameters:
state
- theState
used to generate the outcome for this transitionnext
- the name of the nextState
to execute- Returns:
StateTransition
that was created.
-
createStateTransition
public static StateTransition createStateTransition(State state, @Nullable String pattern, @Nullable String next) Create a newStateTransition
specification from oneState
to another (by name).- Parameters:
state
- theState
used to generate the outcome for this transitionpattern
- the pattern to match in the exit status of theState
(can benull
)next
- the name of the nextState
to execute (can benull
)- Returns:
StateTransition
that 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
-