Class MongoCursorItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.data.builder.MongoCursorItemReaderBuilder<T>
- Since:
- 5.1
- Author:
- LEE Juchan, Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbatchSize
(int batchSize) The size of batches to use when iterating over results.build()
collection
(String collection) Establish an optional collection that can be queried.currentItemCount
(int currentItemCount) Index for the current item.JSON defining the fields to be returned from the matching documents by MongoDB.JSON String telling MongoDB what index to use.A JSON formatted MongoDB jsonQuery.limit
(int limit) The query limitmaxItemCount
(int maxItemCount) Configure the max number of items to be read.The maximum execution time for the queryThe name used to calculate the key within theExecutionContext
.parameterValues
(List<Object> parameterValues) Values to be substituted in for each of the parameters in the query.query
(org.springframework.data.mongodb.core.query.Query query) Provide a Spring Data MongoQuery
.saveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.Map
of property names/Sort.Direction
values to sort the input by.targetType
(Class<? extends T> targetType) The targetType of object to be returned for eachAbstractItemCountingItemStreamItemReader.read()
call.template
(org.springframework.data.mongodb.core.MongoOperations template) Used to perform operations against the MongoDB instance.
-
Constructor Details
-
MongoCursorItemReaderBuilder
public MongoCursorItemReaderBuilder()
-
-
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:
-
template
public MongoCursorItemReaderBuilder<T> template(org.springframework.data.mongodb.core.MongoOperations template) Used to perform operations against the MongoDB instance. Also handles the mapping of documents to objects.- Parameters:
template
- the MongoOperations instance to use- Returns:
- The current instance of the builder
- See Also:
-
MongoOperations
MongoCursorItemReader.setTemplate(MongoOperations)
-
targetType
The targetType of object to be returned for eachAbstractItemCountingItemStreamItemReader.read()
call.- Parameters:
targetType
- the targetType of object to return- Returns:
- The current instance of the builder
- See Also:
-
collection
Establish an optional collection that can be queried.- Parameters:
collection
- Mongo collection to be queried.- Returns:
- The current instance of the builder
- See Also:
-
query
public MongoCursorItemReaderBuilder<T> query(org.springframework.data.mongodb.core.query.Query query) Provide a Spring Data MongoQuery
. This will take precedence over a JSON configured query.- Parameters:
query
- Query to execute- Returns:
- this instance for method chaining
- See Also:
-
jsonQuery
A JSON formatted MongoDB jsonQuery. Parameterization of the provided jsonQuery is allowed via ?<index> placeholders where the <index> indicates the index of the parameterValue to substitute.- Parameters:
query
- JSON formatted Mongo jsonQuery- Returns:
- The current instance of the builder
- See Also:
-
parameterValues
Values to be substituted in for each of the parameters in the query.- Parameters:
parameterValues
- values- Returns:
- The current instance of the builder
- See Also:
-
fields
JSON defining the fields to be returned from the matching documents by MongoDB.- Parameters:
fields
- JSON string that identifies the fields to sort by.- Returns:
- The current instance of the builder
- See Also:
-
sorts
public MongoCursorItemReaderBuilder<T> sorts(Map<String, org.springframework.data.domain.Sort.Direction> sorts) Map
of property names/Sort.Direction
values to sort the input by.- Parameters:
sorts
- map of properties and direction to sort each.- Returns:
- The current instance of the builder
- See Also:
-
hint
JSON String telling MongoDB what index to use.- Parameters:
hint
- string indicating what index to use.- Returns:
- The current instance of the builder
- See Also:
-
batchSize
The size of batches to use when iterating over results.- Parameters:
batchSize
- string indicating what index to use.- Returns:
- The current instance of the builder
- See Also:
-
limit
The query limit- Parameters:
limit
- The limit- Returns:
- The current instance of the builder
- See Also:
-
maxTime
The maximum execution time for the query- Parameters:
maxTime
- The max time- Returns:
- The current instance of the builder
- See Also:
-
build
-