类 MongoItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.data.builder.MongoItemReaderBuilder<T>
public class MongoItemReaderBuilder<T> extends java.lang.Object
A builder implementation for theMongoItemReader- 从以下版本开始:
- 4.0
- 作者:
- Glenn Renfro, Mahmoud Ben Hassine
- 另请参阅:
MongoItemReader
字段概要
字段 修饰符和类型 字段 说明 protected intpageSize
构造器概要
构造器 构造器 说明 MongoItemReaderBuilder()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 MongoItemReader<T>build()Validates and builds aMongoItemReader.MongoItemReaderBuilder<T>collection(java.lang.String collection)Establish an optional collection that can be queried.MongoItemReaderBuilder<T>currentItemCount(int currentItemCount)Index for the current item.MongoItemReaderBuilder<T>fields(java.lang.String fields)JSON defining the fields to be returned from the matching documents by MongoDB.MongoItemReaderBuilder<T>hint(java.lang.String hint)JSON String telling MongoDB what index to use.MongoItemReaderBuilder<T>jsonQuery(java.lang.String query)A JSON formatted MongoDB jsonQuery.MongoItemReaderBuilder<T>maxItemCount(int maxItemCount)Configure the max number of items to be read.MongoItemReaderBuilder<T>name(java.lang.String name)The name used to calculate the key within theExecutionContext.MongoItemReaderBuilder<T>pageSize(int pageSize)The number of items to be read with each page.MongoItemReaderBuilder<T>parameterValues(java.util.List<java.lang.Object> parameterValues)Listof values to be substituted in for each of the parameters in the query.MongoItemReaderBuilder<T>query(org.springframework.data.mongodb.core.query.Query query)Provide a Spring Data MongoQuery.MongoItemReaderBuilder<T>saveState(boolean saveState)Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.MongoItemReaderBuilder<T>sorts(java.util.Map<java.lang.String,org.springframework.data.domain.Sort.Direction> sorts)Mapof property names/Sort.Directionvalues to sort the input by.MongoItemReaderBuilder<T>targetType(java.lang.Class<? extends T> targetType)The type of object to be returned for eachAbstractItemCountingItemStreamItemReader.read()call.MongoItemReaderBuilder<T>template(org.springframework.data.mongodb.core.MongoOperations template)Used to perform operations against the MongoDB instance.
字段详细资料
pageSize
protected int pageSize
构造器详细资料
MongoItemReaderBuilder
public MongoItemReaderBuilder()
方法详细资料
saveState
public MongoItemReaderBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- 参数:
saveState- defaults to true- 返回:
- The current instance of the builder.
name
public MongoItemReaderBuilder<T> name(java.lang.String name)
The name used to calculate the key within theExecutionContext. Required ifsaveState(boolean)is set to true.- 参数:
name- name of the reader instance- 返回:
- The current instance of the builder.
- 另请参阅:
ItemStreamSupport.setName(String)
maxItemCount
public MongoItemReaderBuilder<T> maxItemCount(int maxItemCount)
Configure the max number of items to be read.- 参数:
maxItemCount- the max items to be read- 返回:
- The current instance of the builder.
- 另请参阅:
AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
currentItemCount
public MongoItemReaderBuilder<T> currentItemCount(int currentItemCount)
Index for the current item. Used on restarts to indicate where to start from.- 参数:
currentItemCount- current index- 返回:
- this instance for method chaining
- 另请参阅:
AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
template
public MongoItemReaderBuilder<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.- 参数:
template- the MongoOperations instance to use- 返回:
- The current instance of the builder
- 另请参阅:
MongoOperations,MongoItemReader.setTemplate(MongoOperations)
jsonQuery
public MongoItemReaderBuilder<T> jsonQuery(java.lang.String query)
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.- 参数:
query- JSON formatted Mongo jsonQuery- 返回:
- The current instance of the builder
- 另请参阅:
MongoItemReader.setQuery(String)
targetType
public MongoItemReaderBuilder<T> targetType(java.lang.Class<? extends T> targetType)
The type of object to be returned for eachAbstractItemCountingItemStreamItemReader.read()call.- 参数:
targetType- the type of object to return- 返回:
- The current instance of the builder
- 另请参阅:
MongoItemReader.setTargetType(Class)
parameterValues
public MongoItemReaderBuilder<T> parameterValues(java.util.List<java.lang.Object> parameterValues)
Listof values to be substituted in for each of the parameters in the query.- 参数:
parameterValues- values- 返回:
- The current instance of the builder
- 另请参阅:
MongoItemReader.setParameterValues(List)
fields
public MongoItemReaderBuilder<T> fields(java.lang.String fields)
JSON defining the fields to be returned from the matching documents by MongoDB.- 参数:
fields- JSON string that identifies the fields to sort by.- 返回:
- The current instance of the builder
- 另请参阅:
MongoItemReader.setFields(String)
sorts
public MongoItemReaderBuilder<T> sorts(java.util.Map<java.lang.String,org.springframework.data.domain.Sort.Direction> sorts)
Mapof property names/Sort.Directionvalues to sort the input by.- 参数:
sorts- map of properties and direction to sort each.- 返回:
- The current instance of the builder
- 另请参阅:
MongoItemReader.setSort(Map)
collection
public MongoItemReaderBuilder<T> collection(java.lang.String collection)
Establish an optional collection that can be queried.- 参数:
collection- Mongo collection to be queried.- 返回:
- The current instance of the builder
- 另请参阅:
MongoItemReader.setCollection(String)
hint
public MongoItemReaderBuilder<T> hint(java.lang.String hint)
JSON String telling MongoDB what index to use.- 参数:
hint- string indicating what index to use.- 返回:
- The current instance of the builder
- 另请参阅:
MongoItemReader.setHint(String)
pageSize
public MongoItemReaderBuilder<T> pageSize(int pageSize)
The number of items to be read with each page.- 参数:
pageSize- the number of items- 返回:
- this instance for method chaining
- 另请参阅:
AbstractPaginatedDataItemReader.setPageSize(int)
query
public MongoItemReaderBuilder<T> query(org.springframework.data.mongodb.core.query.Query query)
Provide a Spring Data MongoQuery. This will take precedence over a JSON configured query.- 参数:
query- Query to execute- 返回:
- this instance for method chaining
- 另请参阅:
MongoItemReader.setQuery(Query)
build
public MongoItemReader<T> build()
Validates and builds aMongoItemReader.- 返回:
- a
MongoItemReader