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:
-
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
(org.springframework.data.repository.PagingAndSortingRepository<T, ?> 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<T, ?> 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:
-
build
Builds theRepositoryItemReader
.- Returns:
- a
RepositoryItemReader
-