Class MongoCursor<ResultT>

  • Type Parameters:
    ResultT - The type of documents the cursor contains
    All Implemented Interfaces:
    Closeable, AutoCloseable, Iterator<ResultT>

    public class MongoCursor<ResultT>
    extends Object
    implements Iterator<ResultT>, Closeable
    The Mongo Cursor class is fundamentally an Iterator containing an additional tryNext() method for convenience.

    An application should ensure that a cursor is closed in all circumstances, e.g. using a try-with-resources statement.

    • Method Detail

      • tryNext

        public ResultT tryNext()
        A special next() case that returns the next document if available or null.
        Returns:
        A Task containing the next document if available or null.