org.springframework.batch.jsr.repeat

## Class CheckpointAlgorithmAdapter

- java.lang.Object
- - org.springframework.batch.jsr.repeat.CheckpointAlgorithmAdapter

- All Implemented Interfaces:
    CompletionPolicy

      public class CheckpointAlgorithmAdapter
      extends java.lang.Object
      implements CompletionPolicy

  Wrapper for the `CheckpointAlgorithm` to be used via the rest of the framework.
  Author:
    Michael Minella
  See Also:
    `CheckpointAlgorithm`, `CompletionPolicy`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CheckpointAlgorithmAdapter(javax.batch.api.chunk.CheckpointAlgorithm policy)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isComplete(RepeatContext context)` Allow policy to signal completion according to internal state, without having to wait for the callback to complete.
    `boolean` | `isComplete(RepeatContext context, RepeatStatus result)` Determine whether a batch is complete given the latest result from the callback.
    `RepeatContext` | `start(RepeatContext parent)` Create a new context for the execution of a batch.
    `void` | `update(RepeatContext context)` If `CheckpointAlgorithm.isReadyToCheckpoint()` is true we will call `CheckpointAlgorithm.endCheckpoint()`

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

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

- - ### Constructor Detail

    - #### CheckpointAlgorithmAdapter

          public CheckpointAlgorithmAdapter(javax.batch.api.chunk.CheckpointAlgorithm policy)

  - ### Method Detail

    - #### isComplete

          public boolean isComplete(RepeatContext context,
                                    RepeatStatus result)

      Description copied from interface: `CompletionPolicy`
      Determine whether a batch is complete given the latest result from the callback. If this method returns true then `CompletionPolicy.isComplete(RepeatContext)` should also (but not necessarily vice versa, since the answer here depends on the result).
      Specified by:
        `isComplete` in interface `CompletionPolicy`
      Parameters:
        `context` - the current batch context.
        `result` - the result of the latest batch item processing.
      Returns:
        true if the batch should terminate.
      See Also:
        `CompletionPolicy.isComplete(RepeatContext)`

    - #### isComplete

          public boolean isComplete(RepeatContext context)

      Description copied from interface: `CompletionPolicy`
      Allow policy to signal completion according to internal state, without having to wait for the callback to complete.
      Specified by:
        `isComplete` in interface `CompletionPolicy`
      Parameters:
        `context` - the current batch context.
      Returns:
        true if the batch should terminate.

    - #### start

          public RepeatContext start(RepeatContext parent)

      Description copied from interface: `CompletionPolicy`
      Create a new context for the execution of a batch. N.B. implementations should not return the parent from this method - they must create a new context to meet the specific needs of the policy. The best way to do this might be to override an existing implementation and use the `RepeatContext` to store state in its attributes.
      Specified by:
        `start` in interface `CompletionPolicy`
      Parameters:
        `parent` - the current context if one is already in progress.
      Returns:
        a context object that can be used by the implementation to store internal state for a batch.

    - #### update

          public void update(RepeatContext context)

      If `CheckpointAlgorithm.isReadyToCheckpoint()` is true we will call `CheckpointAlgorithm.endCheckpoint()`
      Specified by:
        `update` in interface `CompletionPolicy`
      Parameters:
        `context` - a `RepeatContext`