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