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 |
|---|---|
MappingIterable<U,V> |
batchSize(int batchSize)
Sets the number of documents to return per batch.
|
V |
first()
Helper to return the first item in the iterator or null.
|
void |
forEach(Block<? super V> block)
Iterates over all documents in the view, applying the given block to each.
|
<A extends java.util.Collection<? super V>> |
into(A target)
Iterates over all the documents, adding each to the given target.
|
MongoCursor<V> |
iterator() |
<W> MongoIterable<W> |
map(Function<V,W> newMap)
Maps this iterable from the source document type to the target document type.
|
private final MongoIterable<U> iterable
public MappingIterable(MongoIterable<U> iterable, Function<U,V> mapper)
public MongoCursor<V> iterator()
iterator in interface MongoIterable<V>iterator in interface java.lang.Iterable<V>public V first()
MongoIterablefirst in interface MongoIterable<V>public void forEach(Block<? super V> block)
MongoIterableSimilar to map but the function is fully encapsulated with no returned result.
forEach in interface MongoIterable<V>block - the block to apply to each document of type T.public <A extends java.util.Collection<? super V>> A into(A target)
MongoIterableinto in interface MongoIterable<V>A - the collection typetarget - the collection to insert intopublic MappingIterable<U,V> batchSize(int batchSize)
MongoIterablebatchSize in interface MongoIterable<V>batchSize - the batch sizepublic <W> MongoIterable<W> map(Function<V,W> newMap)
MongoIterablemap in interface MongoIterable<V>W - the target document typenewMap - a function that maps from the source to the target document type