Class RepositoryItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.data.builder.RepositoryItemReaderBuilder<T>
A builder implementation for the
RepositoryItemReader
.- Since:
- 4.0
- Author:
- Glenn Renfro, Mahmoud Ben Hassine, Drummond Dawson
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Establishes a proxy that will capture a the Repository and the associated methodName that will be used by the reader. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionArguments to be passed to the data providing method.Arguments to be passed to the data providing method.build()
Builds theRepositoryItemReader
.currentItemCount
(int currentItemCount) Index for the current item.maxItemCount
(int maxItemCount) Configure the max number of items to be read.methodName
(String methodName) Specifies what method on the repository to call.The name used to calculate the key within theExecutionContext
.pageSize
(int pageSize) Establish the pageSize for the generated RepositoryItemReader.repository
(RepositoryItemReaderBuilder.RepositoryMethodReference<?> repositoryMethodReference) Specifies a repository and the type-safe method to call for the reader.repository
(org.springframework.data.repository.PagingAndSortingRepository<?, ?> repository) ThePagingAndSortingRepository
implementation used to read input from.saveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.Provides ordering of the results so that order is maintained between paged queries.
-
Constructor Details
-
RepositoryItemReaderBuilder
public RepositoryItemReaderBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true- Returns:
- The current instance of the builder.
-
name
The name used to calculate the key within theExecutionContext
. Required ifsaveState(boolean)
is set to true.- Parameters:
name
- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
-
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:
-
currentItemCount
Index for the current item. Used on restarts to indicate where to start from.- Parameters:
currentItemCount
- current index- Returns:
- this instance for method chaining
- See Also:
-
arguments
Arguments to be passed to the data providing method.- Parameters:
arguments
- list of method arguments to be passed to the repository.- Returns:
- The current instance of the builder.
- See Also:
-
arguments
Arguments to be passed to the data providing method.- Parameters:
arguments
- the method arguments to be passed to the repository.- Returns:
- The current instance of the builder.
- See Also:
-
sorts
public RepositoryItemReaderBuilder<T> sorts(Map<String, org.springframework.data.domain.Sort.Direction> sorts) Provides ordering of the results so that order is maintained between paged queries.- Parameters:
sorts
- the fields to sort by and the directions.- Returns:
- The current instance of the builder.
- See Also:
-
pageSize
Establish the pageSize for the generated RepositoryItemReader.- Parameters:
pageSize
- The number of items to retrieve per page.- Returns:
- The current instance of the builder.
- See Also:
-
repository
public RepositoryItemReaderBuilder<T> repository(org.springframework.data.repository.PagingAndSortingRepository<?, ?> repository) ThePagingAndSortingRepository
implementation used to read input from.- Parameters:
repository
- underlying repository for input to be read from.- Returns:
- The current instance of the builder.
- See Also:
-
methodName
Specifies what method on the repository to call. This method must takePageable
as the last argument.- Parameters:
methodName
- name of the method to invoke.- Returns:
- The current instance of the builder.
- See Also:
-
repository
public RepositoryItemReaderBuilder<T> repository(RepositoryItemReaderBuilder.RepositoryMethodReference<?> repositoryMethodReference) Specifies a repository and the type-safe method to call for the reader. The method configured via this mechanism must takePageable
as the last argument. This method can be used in place ofrepository(PagingAndSortingRepository)
,methodName(String)
, andarguments(List)
. 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 reader.- Returns:
- The current instance of the builder.
- See Also:
-
build
Builds theRepositoryItemReader
.- Returns:
- a
RepositoryItemReader
-