org.springframework.batch.item.file.builder

## Class MultiResourceItemReaderBuilder<T>

- java.lang.Object
- - org.springframework.batch.item.file.builder.MultiResourceItemReaderBuilder<T>

-     public class MultiResourceItemReaderBuilder<T>
      extends java.lang.Object

  A builder implementation for the `MultiResourceItemReader`.
  Since:
    4.0
  Author:
    Glenn Renfro, Drummond Dawson
  See Also:
    `MultiResourceItemReader`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiResourceItemReaderBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `MultiResourceItemReader<T>` | `build()` Builds the `MultiResourceItemReader`.
    `MultiResourceItemReaderBuilder<T>` | `comparator(java.util.Comparator<org.springframework.core.io.Resource> comparator)` Used to order the injected resources, by default compares `Resource.getFilename()` values.
    `MultiResourceItemReaderBuilder<T>` | `delegate(ResourceAwareItemReaderItemStream<? extends T> delegate)` Establishes the delegate to use for reading the resources provided.
    `MultiResourceItemReaderBuilder<T>` | `name(java.lang.String name)` The name used to calculate the key within the `ExecutionContext`.
    `MultiResourceItemReaderBuilder<T>` | `resources(org.springframework.core.io.Resource... resources)` The array of resources that the `MultiResourceItemReader` will use to retrieve items.
    `MultiResourceItemReaderBuilder<T>` | `saveState(boolean saveState)` Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
    `MultiResourceItemReaderBuilder<T>` | `setStrict(boolean strict)` In strict mode the reader will throw an exception on `MultiResourceItemReader.open(org.springframework.batch.item.ExecutionContext)` if there are no resources to read.

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

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

- - ### Constructor Detail

    - #### MultiResourceItemReaderBuilder

          public MultiResourceItemReaderBuilder()

  - ### Method Detail

    - #### saveState

          public MultiResourceItemReaderBuilder<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.

    - #### name

          public MultiResourceItemReaderBuilder<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)`

    - #### resources

          public MultiResourceItemReaderBuilder<T> resources(org.springframework.core.io.Resource... resources)

      The array of resources that the `MultiResourceItemReader` will use to retrieve items.
      Parameters:
        `resources` - the array of resources to use.
      Returns:
        this instance for method chaining.
      See Also:
        `MultiResourceItemReader.setResources(Resource[])`

    - #### delegate

          public MultiResourceItemReaderBuilder<T> delegate(ResourceAwareItemReaderItemStream<? extends T> delegate)

      Establishes the delegate to use for reading the resources provided.
      Parameters:
        `delegate` - reads items from single `Resource`.
      Returns:
        this instance for method chaining.
      See Also:
        `MultiResourceItemReader.setDelegate(ResourceAwareItemReaderItemStream)`

    - #### setStrict

          public MultiResourceItemReaderBuilder<T> setStrict(boolean strict)

      In strict mode the reader will throw an exception on `MultiResourceItemReader.open(org.springframework.batch.item.ExecutionContext)` if there are no resources to read.
      Parameters:
        `strict` - false by default.
      Returns:
        this instance for method chaining.
      See Also:
        `MultiResourceItemReader.setStrict(boolean)`

    - #### comparator

          public MultiResourceItemReaderBuilder<T> comparator(java.util.Comparator<org.springframework.core.io.Resource> comparator)

      Used to order the injected resources, by default compares `Resource.getFilename()` values.
      Parameters:
        `comparator` - the comparator to use for ordering resources.
      Returns:
        this instance for method chaining.
      See Also:
        `MultiResourceItemReader.setComparator(Comparator)`

    - #### build

          public MultiResourceItemReader<T> build()

      Builds the `MultiResourceItemReader`.
      Returns:
        a `MultiResourceItemReader`