Class RepositoryItemWriterBuilder<T>
- java.lang.Object
- org.springframework.batch.item.data.builder.RepositoryItemWriterBuilder<T>
public class RepositoryItemWriterBuilder<T> extends java.lang.Object
A builder implementation for theRepositoryItemWriter
.- Since:
- 4.0
- Author:
- Glenn Renfro
- 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RepositoryItemWriter<T>
build()
Builds theRepositoryItemWriter
.RepositoryItemWriterBuilder<T>
methodName(java.lang.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 theCrudRepository
implementation for persistence
Method Detail
methodName
public RepositoryItemWriterBuilder<T> methodName(java.lang.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 theCrudRepository
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 takePageable
as the last argument. This method can be used in place ofrepository(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 theRepositoryItemWriter
.- Returns:
- a
RepositoryItemWriter