Class MongoPagingItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.data.builder.MongoItemReaderBuilder<T>
org.springframework.batch.item.data.builder.MongoPagingItemReaderBuilder<T>
- Type Parameters:
T- type of items to read.
Builder for
MongoPagingItemReader.- Since:
- 5.1
- Author:
- Glenn Renfro, Mahmoud Ben Hassine, Drummond Dawson, Parikshit Dutta
-
Field Summary
Fields inherited from class org.springframework.batch.item.data.builder.MongoItemReaderBuilder
collection, currentItemCount, fields, hint, jsonQuery, maxItemCount, name, pageSize, parameterValues, query, saveState, sorts, targetType, template -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Validates and builds aMongoItemReader.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.maxItemCount(int maxItemCount) Configure the max number of items to be read.The name used to calculate the key within theExecutionContext.pageSize(int pageSize) The number of items to be read with each page.parameterValues(Object... parameterValues) Values to be substituted in for each of the parameters in the query.parameterValues(List<Object> parameterValues) Listof 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 theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.Mapof property names/Sort.Directionvalues to sort the input by.targetType(Class<? extends T> targetType) The type 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
-
MongoPagingItemReaderBuilder
public MongoPagingItemReaderBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- Overrides:
saveStatein classMongoItemReaderBuilder<T>- 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.- Overrides:
namein classMongoItemReaderBuilder<T>- 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.- Overrides:
maxItemCountin classMongoItemReaderBuilder<T>- 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.- Overrides:
currentItemCountin classMongoItemReaderBuilder<T>- Parameters:
currentItemCount- current index- Returns:
- this instance for method chaining
- See Also:
-
template
public MongoPagingItemReaderBuilder<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.- Overrides:
templatein classMongoItemReaderBuilder<T>- Parameters:
template- the MongoOperations instance to use- Returns:
- The current instance of the builder
- See Also:
-
MongoOperationsMongoPagingItemReader.setTemplate(MongoOperations)
-
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.- Overrides:
jsonQueryin classMongoItemReaderBuilder<T>- Parameters:
query- JSON formatted Mongo jsonQuery- Returns:
- The current instance of the builder
- See Also:
-
targetType
The type of object to be returned for eachAbstractItemCountingItemStreamItemReader.read()call.- Overrides:
targetTypein classMongoItemReaderBuilder<T>- Parameters:
targetType- the type of object to return- Returns:
- The current instance of the builder
- See Also:
-
parameterValues
Listof values to be substituted in for each of the parameters in the query.- Overrides:
parameterValuesin classMongoItemReaderBuilder<T>- Parameters:
parameterValues- values- Returns:
- The current instance of the builder
- See Also:
-
parameterValues
Values to be substituted in for each of the parameters in the query.- Overrides:
parameterValuesin classMongoItemReaderBuilder<T>- 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.- Overrides:
fieldsin classMongoItemReaderBuilder<T>- Parameters:
fields- JSON string that identifies the fields to sort by.- Returns:
- The current instance of the builder
- See Also:
-
sorts
public MongoPagingItemReaderBuilder<T> sorts(Map<String, org.springframework.data.domain.Sort.Direction> sorts) Mapof property names/Sort.Directionvalues to sort the input by.- Overrides:
sortsin classMongoItemReaderBuilder<T>- Parameters:
sorts- map of properties and direction to sort each.- Returns:
- The current instance of the builder
- See Also:
-
collection
Establish an optional collection that can be queried.- Overrides:
collectionin classMongoItemReaderBuilder<T>- Parameters:
collection- Mongo collection to be queried.- Returns:
- The current instance of the builder
- See Also:
-
hint
JSON String telling MongoDB what index to use.- Overrides:
hintin classMongoItemReaderBuilder<T>- Parameters:
hint- string indicating what index to use.- Returns:
- The current instance of the builder
- See Also:
-
pageSize
The number of items to be read with each page.- Overrides:
pageSizein classMongoItemReaderBuilder<T>- Parameters:
pageSize- the number of items- Returns:
- this instance for method chaining
- See Also:
-
query
public MongoPagingItemReaderBuilder<T> query(org.springframework.data.mongodb.core.query.Query query) Provide a Spring Data MongoQuery. This will take precedence over a JSON configured query.- Overrides:
queryin classMongoItemReaderBuilder<T>- Parameters:
query- Query to execute- Returns:
- this instance for method chaining
- See Also:
-
build
Description copied from class:MongoItemReaderBuilderValidates and builds aMongoItemReader.- Overrides:
buildin classMongoItemReaderBuilder<T>- Returns:
- a
MongoItemReader
-