org.springframework.batch.item.file.builder

## Class MultiResourceItemWriterBuilder<T>

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

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

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiResourceItemWriterBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `MultiResourceItemWriter<T>` | `build()` Builds the `MultiResourceItemWriter`.
    `MultiResourceItemWriterBuilder<T>` | `delegate(ResourceAwareItemWriterItemStream<? super T> delegate)` Delegate used for actual writing of the output.
    `MultiResourceItemWriterBuilder<T>` | `itemCountLimitPerResource(int itemCountLimitPerResource)` After this limit is exceeded the next chunk will be written into newly created resource.
    `MultiResourceItemWriterBuilder<T>` | `name(java.lang.String name)` The name used to calculate the key within the `ExecutionContext`.
    `MultiResourceItemWriterBuilder<T>` | `resource(org.springframework.core.io.Resource resource)` Prototype for output resources.
    `MultiResourceItemWriterBuilder<T>` | `resourceSuffixCreator(ResourceSuffixCreator suffixCreator)` Allows customization of the suffix of the created resources based on the index.
    `MultiResourceItemWriterBuilder<T>` | `saveState(boolean saveState)` Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.

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

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

- - ### Constructor Detail

    - #### MultiResourceItemWriterBuilder

          public MultiResourceItemWriterBuilder()

  - ### Method Detail

    - #### saveState

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

    - #### resourceSuffixCreator

          public MultiResourceItemWriterBuilder<T> resourceSuffixCreator(ResourceSuffixCreator suffixCreator)

      Allows customization of the suffix of the created resources based on the index.
      Parameters:
        `suffixCreator` - the customizable ResourceSuffixCreator to use.
      Returns:
        The current instance of the builder.
      See Also:
        `MultiResourceItemWriter.setResourceSuffixCreator(ResourceSuffixCreator)`

    - #### itemCountLimitPerResource

          public MultiResourceItemWriterBuilder<T> itemCountLimitPerResource(int itemCountLimitPerResource)

      After this limit is exceeded the next chunk will be written into newly created resource.
      Parameters:
        `itemCountLimitPerResource` - the max numbers of items to be written per chunk.
      Returns:
        The current instance of the builder.
      See Also:
        `MultiResourceItemWriter.setItemCountLimitPerResource(int)`

    - #### delegate

          public MultiResourceItemWriterBuilder<T> delegate(ResourceAwareItemWriterItemStream<? super T> delegate)

      Delegate used for actual writing of the output.
      Parameters:
        `delegate` - The delegate to use for writing.
      Returns:
        The current instance of the builder.
      See Also:
        `MultiResourceItemWriter.setDelegate(ResourceAwareItemWriterItemStream)`

    - #### resource

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

      Prototype for output resources. Actual output files will be created in the same directory and use the same name as this prototype with appended suffix (according to `MultiResourceItemWriter.setResourceSuffixCreator(ResourceSuffixCreator)`.
      Parameters:
        `resource` - the prototype resource to use as the basis for creating resources.
      Returns:
        The current instance of the builder.
      See Also:
        `MultiResourceItemWriter.setResource(Resource)`

    - #### build

          public MultiResourceItemWriter<T> build()

      Builds the `MultiResourceItemWriter`.
      Returns:
        a `MultiResourceItemWriter`