T
- The type of documents the cursor contains@NotThreadSafe public interface MongoCursor<T> extends Iterator<T>, Closeable
Modifier and Type | Method and Description |
---|---|
void |
close() |
ServerAddress |
getServerAddress()
Returns the server address
|
ServerCursor |
getServerCursor()
Returns the server cursor
|
boolean |
hasNext() |
T |
next() |
T |
tryNext()
A special
next() case that returns the next element in the iteration if available or null. |
void close()
close
in interface AutoCloseable
close
in interface Closeable
T tryNext()
next()
case that returns the next element in the iteration 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 element if a document had been added to the capped collection.
ServerCursor getServerCursor()
ServerAddress getServerAddress()