Package org.springframework.batch.core.job.builder

# Class FlowBuilder<Q>

java.lang.Object
org.springframework.batch.core.job.builder.FlowBuilder<Q>

Type Parameters:
  `Q` - the type of object returned by the builder (by default a Flow)

Direct Known Subclasses:
  `JobFlowBuilder`

public class FlowBuilder<Q> extends Object
A builder for a flow of steps that can be executed as a job or as part of a job. Steps can be linked together with conditional transitions that depend on the exit status of the previous step.

Since:
  2.2
Author:
  Dave Syer, Michael Minella

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `FlowBuilder.SplitBuilder<Q>`
  A builder for building a split state.
  `static class`
  `FlowBuilder.TransitionBuilder<Q>`
  A builder for transitions within a flow.
  `static class`
  `FlowBuilder.UnterminatedFlowBuilder<Q>`
  A builder for continuing a flow from a decision state.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FlowBuilder(String name)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Q`
  `build()`
  Validate the current state of the builder and build a flow.
  `final Q`
  `end()`
  A synonym for `build()` which callers might find useful.
  `protected Flow`
  `flow()`
  `FlowBuilder<Q>`
  `from(Flow flow)`
  Start again from a subflow that was already registered.
  `FlowBuilder.UnterminatedFlowBuilder<Q>`
  `from(JobExecutionDecider decider)`
  Start again from a decision that was already registered.
  `FlowBuilder<Q>`
  `from(Step step)`
  Go back to a previously registered step and start a new path.
  `FlowBuilder<Q>`
  `next(Flow flow)`
  Go next on successful completion to a subflow.
  `FlowBuilder.UnterminatedFlowBuilder<Q>`
  `next(JobExecutionDecider decider)`
  Transition to the decider on successful completion of the current step.
  `FlowBuilder<Q>`
  `next(Step step)`
  Transition to the next step on successful completion of the current step.
  `FlowBuilder.TransitionBuilder<Q>`
  `on(String pattern)`
  Start a transition to a new state if the exit status from the previous state matches the pattern given.
  `FlowBuilder.SplitBuilder<Q>`
  `split(org.springframework.core.task.TaskExecutor executor)`
  `FlowBuilder<Q>`
  `start(Flow flow)`
  If a flow should start with a subflow use this as the first state.
  `FlowBuilder.UnterminatedFlowBuilder<Q>`
  `start(JobExecutionDecider decider)`
  If a flow should start with a decision use this as the first state.
  `FlowBuilder<Q>`
  `start(Step step)`
  Start a flow.
  `protected void`
  `stop(String pattern)`
  `protected void`
  `stop(String pattern, State restart)`

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

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

- ## Constructor Details

  - ### FlowBuilder

    public FlowBuilder(String name)

- ## Method Details

  - ### build

    public Q build()
    Validate the current state of the builder and build a flow. Subclasses may override this to build an object of a different type that itself depends on the flow.
    Returns:
      a flow

  - ### next

    public FlowBuilder<Q> next(Step step)
    Transition to the next step on successful completion of the current step. All other outcomes are treated as failures.
    Parameters:
      `step` - the next step
    Returns:
      this to enable chaining

  - ### start

    public FlowBuilder<Q> start(Step step)
    Start a flow. If some steps are already registered, just a synonym for `from(Step)`.
    Parameters:
      `step` - the step to start with
    Returns:
      this to enable chaining

  - ### from

    public FlowBuilder<Q> from(Step step)
    Go back to a previously registered step and start a new path. If no steps are registered yet just a synonym for `start(Step)`.
    Parameters:
      `step` - the step to start from (already registered)
    Returns:
      this to enable chaining

  - ### next

    public FlowBuilder.UnterminatedFlowBuilder<Q> next(JobExecutionDecider decider)
    Transition to the decider on successful completion of the current step. All other outcomes are treated as failures.
    Parameters:
      `decider` - the JobExecutionDecider to determine the next step to execute
    Returns:
      this to enable chaining

  - ### start

    public FlowBuilder.UnterminatedFlowBuilder<Q> start(JobExecutionDecider decider)
    If a flow should start with a decision use this as the first state.
    Parameters:
      `decider` - the to start from
    Returns:
      a builder to enable chaining

  - ### from

    public FlowBuilder.UnterminatedFlowBuilder<Q> from(JobExecutionDecider decider)
    Start again from a decision that was already registered.
    Parameters:
      `decider` - the decider to start from (already registered)
    Returns:
      a builder to enable chaining

  - ### next

    public FlowBuilder<Q> next(Flow flow)
    Go next on successful completion to a subflow.
    Parameters:
      `flow` - the flow to go to
    Returns:
      a builder to enable chaining

  - ### from

    public FlowBuilder<Q> from(Flow flow)
    Start again from a subflow that was already registered.
    Parameters:
      `flow` - the flow to start from (already registered)
    Returns:
      a builder to enable chaining

  - ### start

    public FlowBuilder<Q> start(Flow flow)
    If a flow should start with a subflow use this as the first state.
    Parameters:
      `flow` - the flow to start from
    Returns:
      a builder to enable chaining

  - ### split

    public FlowBuilder.SplitBuilder<Q> split(org.springframework.core.task.TaskExecutor executor)
    Parameters:
      `executor` - a task executor to execute the split flows
    Returns:
      a builder to enable fluent chaining

  - ### on

    public FlowBuilder.TransitionBuilder<Q> on(String pattern)
    Start a transition to a new state if the exit status from the previous state matches the pattern given. Successful completion normally results in an exit status equal to (or starting with by convention) "COMPLETED". See `ExitStatus` for commonly used values.
    Parameters:
      `pattern` - the pattern of exit status on which to take this transition
    Returns:
      a builder to enable fluent chaining

  - ### end

    public final Q end()
    A synonym for `build()` which callers might find useful. Subclasses can override build to create an object of the desired type (e.g. a parent builder or an actual flow).
    Returns:
      the result of the builder

  - ### flow

    protected Flow flow()

  - ### stop

    protected void stop(String pattern)

  - ### stop

    protected void stop(String pattern, State restart)