Class MorphiaCursor<T>

  • Type Parameters:
    T - the original type being iterated
    All Implemented Interfaces:
    com.mongodb.client.MongoCursor<T>, Closeable, AutoCloseable, Iterator<T>
    Direct Known Subclasses:
    MorphiaCursor

    public class MorphiaCursor<T>
    extends Object
    implements com.mongodb.client.MongoCursor<T>
    Since:
    2.2
    • Constructor Detail

      • MorphiaCursor

        public MorphiaCursor​(com.mongodb.client.MongoCursor<T> cursor)
        Creates a MorphiaCursor
        Parameters:
        cursor - the Iterator to use
    • Method Detail

      • close

        public void close()
        Closes the underlying cursor.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface com.mongodb.client.MongoCursor<T>
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<T>
        Specified by:
        hasNext in interface com.mongodb.client.MongoCursor<T>
      • next

        @NonNull
        public T next()
        Specified by:
        next in interface Iterator<T>
        Specified by:
        next in interface com.mongodb.client.MongoCursor<T>
      • tryNext

        public T tryNext()
        Specified by:
        tryNext in interface com.mongodb.client.MongoCursor<T>
      • getServerCursor

        public com.mongodb.ServerCursor getServerCursor()
        Specified by:
        getServerCursor in interface com.mongodb.client.MongoCursor<T>
      • getServerAddress

        @NonNull
        public com.mongodb.ServerAddress getServerAddress()
        Specified by:
        getServerAddress in interface com.mongodb.client.MongoCursor<T>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<T>
      • toList

        public List<T> toList()
        Converts this cursor to a List. Care should be taken on large datasets as OutOfMemoryErrors are a risk.
        Returns:
        the list of Entities