class MappingIterable<T,U> extends java.lang.Object implements MongoIterable<U>
Modifier and Type | Field and Description |
---|---|
private MongoIterable<T> |
iterable |
private Function<T,U> |
mapper |
Constructor and Description |
---|
MappingIterable(MongoIterable<T> iterable,
Function<T,U> mapper) |
Modifier and Type | Method and Description |
---|---|
void |
batchCursor(SingleResultCallback<AsyncBatchCursor<U>> callback)
Provide the underlying
AsyncBatchCursor allowing fine grained control of the cursor. |
MongoIterable<U> |
batchSize(int batchSize)
Sets the number of documents to return per batch.
|
void |
first(SingleResultCallback<U> callback)
Helper to return the first item in the iterator or null.
|
void |
forEach(Block<? super U> block,
SingleResultCallback<java.lang.Void> callback)
Iterates over all documents in the view, applying the given block to each, and completing the returned future after all documents
have been iterated, or an exception has occurred.
|
<A extends java.util.Collection<? super U>> |
into(A target,
SingleResultCallback<A> callback)
Iterates over all the documents, adding each to the given target.
|
<V> MongoIterable<V> |
map(Function<U,V> mapper)
Maps this iterable from the source document type to the target document type.
|
private final MongoIterable<T> iterable
MappingIterable(MongoIterable<T> iterable, Function<T,U> mapper)
public void first(SingleResultCallback<U> callback)
MongoIterable
first
in interface MongoIterable<U>
callback
- a callback that is passed the first item or null.public void forEach(Block<? super U> block, SingleResultCallback<java.lang.Void> callback)
MongoIterable
forEach
in interface MongoIterable<U>
block
- the block to apply to each documentcallback
- a callback that completed once the iteration has completedpublic <A extends java.util.Collection<? super U>> void into(A target, SingleResultCallback<A> callback)
MongoIterable
into
in interface MongoIterable<U>
A
- the collection typetarget
- the collection to insert intocallback
- a callback that will be passed the target containing all documentspublic <V> MongoIterable<V> map(Function<U,V> mapper)
MongoIterable
map
in interface MongoIterable<U>
V
- the target document typemapper
- a function that maps from the source to the target document typepublic MongoIterable<U> batchSize(int batchSize)
MongoIterable
batchSize
in interface MongoIterable<U>
batchSize
- the batch sizepublic void batchCursor(SingleResultCallback<AsyncBatchCursor<U>> callback)
MongoIterable
AsyncBatchCursor
allowing fine grained control of the cursor.batchCursor
in interface MongoIterable<U>
callback
- a callback that will be passed the AsyncBatchCursor