Package org.springframework.batch.item.data.builder

# Class RepositoryItemWriterBuilder<T>

java.lang.Object
org.springframework.batch.item.data.builder.RepositoryItemWriterBuilder<T>

public class RepositoryItemWriterBuilder<T> extends Object
A builder implementation for the `RepositoryItemWriter`.

Since:
  4.0
Author:
  Glenn Renfro, Mahmoud Ben Hassine
See Also:
  - `RepositoryItemWriter`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `RepositoryItemWriterBuilder.RepositoryMethodReference<T>`
  Establishes a proxy that will capture a the Repository and the associated methodName that will be used by the writer.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RepositoryItemWriterBuilder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `RepositoryItemWriter<T>`
  `build()`
  Builds the `RepositoryItemWriter`.
  `RepositoryItemWriterBuilder<T>`
  `methodName(String methodName)`
  Specifies what method on the repository to call.
  `RepositoryItemWriterBuilder<T>`
  `repository(RepositoryItemWriterBuilder.RepositoryMethodReference repositoryMethodReference)`
  Specifies a repository and the type-safe method to call for the writer.
  `RepositoryItemWriterBuilder<T>`
  `repository(org.springframework.data.repository.CrudRepository<T,?> repository)`
  Set the `CrudRepository` implementation for persistence

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

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

- ## Constructor Details

  - ### RepositoryItemWriterBuilder

    public RepositoryItemWriterBuilder()

- ## Method Details

  - ### methodName

    public RepositoryItemWriterBuilder<T> methodName(String methodName)
    Specifies what method on the repository to call. This method must have the type of object passed to this writer as the sole argument.
    Parameters:
      `methodName` - the name of the method to be used for saving the item.
    Returns:
      The current instance of the builder.
    See Also:
      - `RepositoryItemWriter.setMethodName(String)`

  - ### repository

    public RepositoryItemWriterBuilder<T> repository(org.springframework.data.repository.CrudRepository<T,?> repository)
    Set the `CrudRepository` implementation for persistence
    Parameters:
      `repository` - the Spring Data repository to be set
    Returns:
      The current instance of the builder.
    See Also:
      - `RepositoryItemWriter.setRepository(CrudRepository)`

  - ### repository

    public RepositoryItemWriterBuilder<T> repository(RepositoryItemWriterBuilder.RepositoryMethodReference repositoryMethodReference)
    Specifies a repository and the type-safe method to call for the writer. The method configured via this mechanism must take `Pageable` as the last argument. This method can be used in place of `repository(CrudRepository)`, `methodName(String)`}. Note: The repository that is used by the repositoryMethodReference must be non-final.
    Parameters:
      `repositoryMethodReference` - of the used to get a repository and type-safe method for use by the writer.
    Returns:
      The current instance of the builder.
    See Also:
      - `RepositoryItemWriter.setMethodName(String)`
      - `RepositoryItemWriter.setRepository(CrudRepository)`

  - ### build

    public RepositoryItemWriter<T> build()
    Builds the `RepositoryItemWriter`.
    Returns:
      a `RepositoryItemWriter`