org.springframework.batch.item.json.builder

## Class JsonItemReaderBuilder<T>

- java.lang.Object
- - org.springframework.batch.item.json.builder.JsonItemReaderBuilder<T>

- Type Parameters:
    `T` - type of the target item

      public class JsonItemReaderBuilder<T>
      extends java.lang.Object

  A builder for `JsonItemReader`.
  Since:
    4.1
  Author:
    Mahmoud Ben Hassine

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.commons.logging.Log` | `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsonItemReaderBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JsonItemReader<T>` | `build()` Validate the configuration and build a new `JsonItemReader`.
    `JsonItemReaderBuilder<T>` | `currentItemCount(int currentItemCount)` Index for the current item.
    `JsonItemReaderBuilder<T>` | `jsonObjectReader(JsonObjectReader<T> jsonObjectReader)` Set the `JsonObjectReader` to use to read and map Json objects to domain objects.
    `JsonItemReaderBuilder<T>` | `maxItemCount(int maxItemCount)` Configure the max number of items to be read.
    `JsonItemReaderBuilder<T>` | `name(java.lang.String name)` The name used to calculate the key within the `ExecutionContext`.
    `JsonItemReaderBuilder<T>` | `resource(org.springframework.core.io.Resource resource)` The `Resource` to be used as input.
    `JsonItemReaderBuilder<T>` | `saveState(boolean saveState)` Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
    `JsonItemReaderBuilder<T>` | `strict(boolean strict)` Setting this value to true indicates that it is an error if the input does not exist and an exception will be thrown.

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

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

- - ### Field Detail

    - #### logger

          protected org.apache.commons.logging.Log logger

  - ### Constructor Detail

    - #### JsonItemReaderBuilder

          public JsonItemReaderBuilder()

  - ### Method Detail

    - #### jsonObjectReader

          public JsonItemReaderBuilder<T> jsonObjectReader(JsonObjectReader<T> jsonObjectReader)

      Set the `JsonObjectReader` to use to read and map Json objects to domain objects.
      Parameters:
        `jsonObjectReader` - to use
      Returns:
        The current instance of the builder.
      See Also:
        `JsonItemReader.setJsonObjectReader(JsonObjectReader)`

    - #### resource

          public JsonItemReaderBuilder<T> resource(org.springframework.core.io.Resource resource)

      The `Resource` to be used as input.
      Parameters:
        `resource` - the input to the reader.
      Returns:
        The current instance of the builder.
      See Also:
        `JsonItemReader.setResource(Resource)`

    - #### name

          public JsonItemReaderBuilder<T> name(java.lang.String name)

      The name used to calculate the key within the `ExecutionContext`. Required if `saveState(boolean)` is set to true.
      Parameters:
        `name` - name of the reader instance
      Returns:
        The current instance of the builder.
      See Also:
        `ItemStreamSupport.setName(String)`

    - #### strict

          public JsonItemReaderBuilder<T> strict(boolean strict)

      Setting this value to true indicates that it is an error if the input does not exist and an exception will be thrown. Defaults to true.
      Parameters:
        `strict` - indicates the input resource must exist
      Returns:
        The current instance of the builder.
      See Also:
        `JsonItemReader.setStrict(boolean)`

    - #### saveState

          public JsonItemReaderBuilder<T> saveState(boolean saveState)

      Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
      Parameters:
        `saveState` - defaults to true
      Returns:
        The current instance of the builder.

    - #### maxItemCount

          public JsonItemReaderBuilder<T> maxItemCount(int maxItemCount)

      Configure the max number of items to be read.
      Parameters:
        `maxItemCount` - the max items to be read
      Returns:
        The current instance of the builder.
      See Also:
        `AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)`

    - #### currentItemCount

          public JsonItemReaderBuilder<T> currentItemCount(int currentItemCount)

      Index for the current item. Used on restarts to indicate where to start from.
      Parameters:
        `currentItemCount` - current index
      Returns:
        The current instance of the builder.
      See Also:
        `AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)`

    - #### build

          public JsonItemReader<T> build()

      Validate the configuration and build a new `JsonItemReader`.
      Returns:
        a new instance of the `JsonItemReader`