class MappingAsyncBatchCursor<T,U> extends java.lang.Object implements AsyncBatchCursor<U>
Modifier and Type | Field and Description |
---|---|
private AsyncBatchCursor<T> |
batchCursor |
private Function<T,U> |
mapper |
Constructor and Description |
---|
MappingAsyncBatchCursor(AsyncBatchCursor<T> batchCursor,
Function<T,U> mapper) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
getBatchSize()
Gets the batch size to use when requesting the next batch.
|
private SingleResultCallback<java.util.List<T>> |
getMappingCallback(SingleResultCallback<java.util.List<U>> callback) |
boolean |
isClosed()
Return true if the AsyncBatchCursor has been closed
|
void |
next(SingleResultCallback<java.util.List<U>> callback)
Returns the next batch of results.
|
void |
setBatchSize(int batchSize)
Sets the batch size to use when requesting the next batch.
|
void |
tryNext(SingleResultCallback<java.util.List<U>> callback)
A special
next() case that returns the next batch if available or null. |
private final AsyncBatchCursor<T> batchCursor
MappingAsyncBatchCursor(AsyncBatchCursor<T> batchCursor, Function<T,U> mapper)
public void next(SingleResultCallback<java.util.List<U>> callback)
AsyncBatchCursor
next
in interface AsyncBatchCursor<U>
callback
- callback to receive the next batch of resultspublic void tryNext(SingleResultCallback<java.util.List<U>> callback)
AsyncBatchCursor
next()
case that returns the next batch if available or null.
Tailable cursors are an example where this is useful. A call to tryNext()
may return null, but in the future calling
tryNext()
would return a new batch if a document had been added to the capped collection.
tryNext
in interface AsyncBatchCursor<U>
callback
- callback to receive the next batch of resultspublic void setBatchSize(int batchSize)
AsyncBatchCursor
setBatchSize
in interface AsyncBatchCursor<U>
batchSize
- the non-negative batch size. 0 means to use the server default.public int getBatchSize()
AsyncBatchCursor
getBatchSize
in interface AsyncBatchCursor<U>
public boolean isClosed()
AsyncBatchCursor
isClosed
in interface AsyncBatchCursor<U>
public void close()
close
in interface AsyncBatchCursor<U>
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
private SingleResultCallback<java.util.List<T>> getMappingCallback(SingleResultCallback<java.util.List<U>> callback)