Package org.springframework.batch.core.job.flow.support

# Class SimpleFlow

java.lang.Object
org.springframework.batch.core.job.flow.support.SimpleFlow

All Implemented Interfaces:
  `Flow`, `org.springframework.beans.factory.InitializingBean`

public class SimpleFlow extends Object implements Flow, org.springframework.beans.factory.InitializingBean
A `Flow` that branches conditionally depending on the exit status of the last `State`. The input parameters are the state transitions (in no particular order). The start state name can be specified explicitly (and must exist in the set of transitions), or computed from the existing transitions, if unambiguous.

Since:
  2.0
Author:
  Dave Syer, Michael Minella, Mahmoud Ben Hassine

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SimpleFlow(String name)`
  Create a flow with the given name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `afterPropertiesSet()`
  Locate start state and pre-populate data structures needed for execution.
  `String`
  `getName()`
  Get the name for this flow.
  `State`
  `getStartState()`
  `State`
  `getState(String stateName)`
  Retrieve the State with the given name.
  `protected Map<String,State>`
  `getStateMap()`
  `Collection<State>`
  `getStates()`
  Convenient accessor for clients needing to explore the states of this flow.
  `protected Map<String,Set<StateTransition>>`
  `getTransitionMap()`
  `protected boolean`
  `isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution)`
  `protected State`
  `nextState(String stateName, FlowExecutionStatus status, StepExecution stepExecution)`
  `FlowExecution`
  `resume(String stateName, FlowExecutor executor)`
  `void`
  `setStateTransitionComparator(Comparator<StateTransition> stateTransitionComparator)`
  `void`
  `setStateTransitions(List<StateTransition> stateTransitions)`
  Public setter for the stateTransitions.
  `FlowExecution`
  `start(FlowExecutor executor)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### SimpleFlow

    public SimpleFlow(String name)
    Create a flow with the given name.
    Parameters:
      `name` - the name of the flow

- ## Method Details

  - ### setStateTransitionComparator

    public void setStateTransitionComparator(Comparator<StateTransition> stateTransitionComparator)

  - ### getStartState

    public State getStartState()

  - ### getName

    public String getName()
    Get the name for this flow.
    Specified by:
      `getName` in interface `Flow`
    Returns:
      the name of the flow
    See Also:
      - `Flow.getName()`

  - ### setStateTransitions

    public void setStateTransitions(List<StateTransition> stateTransitions)
    Public setter for the stateTransitions.
    Parameters:
      `stateTransitions` - the stateTransitions to set

  - ### getState

    public State getState(String stateName)
    Retrieve the State with the given name. If there is no State with the given name, then return null.
    Specified by:
      `getState` in interface `Flow`
    Parameters:
      `stateName` - the name of the state to retrieve
    Returns:
      the State

  - ### getStates

    public Collection<State> getStates()
    Convenient accessor for clients needing to explore the states of this flow.
    Specified by:
      `getStates` in interface `Flow`
    Returns:
      the states

  - ### afterPropertiesSet

    public void afterPropertiesSet() throws Exception
    Locate start state and pre-populate data structures needed for execution.
    Specified by:
      `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
    Throws:
      `Exception`
    See Also:
      - `InitializingBean.afterPropertiesSet()`

  - ### start

    public FlowExecution start(FlowExecutor executor) throws FlowExecutionException
    Specified by:
      `start` in interface `Flow`
    Parameters:
      `executor` - the `FlowExecutor` instance to use for the flow execution.
    Returns:
      a `FlowExecution` containing the exit status of the flow.
    Throws:
      `FlowExecutionException` - thrown if error occurs during flow execution.
    See Also:
      - `Flow.start(FlowExecutor)`

  - ### resume

    public FlowExecution resume(String stateName, FlowExecutor executor) throws FlowExecutionException
    Specified by:
      `resume` in interface `Flow`
    Parameters:
      `stateName` - the name of the state to resume on.
      `executor` - the context to be passed into each state executed.
    Returns:
      a `FlowExecution` containing the exit status of the flow.
    Throws:
      `FlowExecutionException` - thrown if error occurs during flow execution.
    See Also:
      - `Flow.resume(String, FlowExecutor)`

  - ### getTransitionMap

    protected Map<String,Set<StateTransition>> getTransitionMap()

  - ### getStateMap

    protected Map<String,State> getStateMap()

  - ### nextState

    protected State nextState(String stateName, FlowExecutionStatus status, StepExecution stepExecution) throws FlowExecutionException
    Parameters:
      `stateName` - the name of the next state.
      `status` - `FlowExecutionStatus` instance.
      `stepExecution` - `StepExecution` instance.
    Returns:
      the next `Step` (or null if this is the end)
    Throws:
      `FlowExecutionException` - thrown if error occurs during nextState processing.

  - ### isFlowContinued

    protected boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution)