Class MorphiaCursor<T>

  • Type Parameters:
    T - the original type being iterated
    All Implemented Interfaces:
    com.mongodb.client.MongoCursor<T>, java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator<T>

    public class MorphiaCursor<T>
    extends java.lang.Object
    implements com.mongodb.client.MongoCursor<T>
    • Constructor Summary

      Constructors 
      Constructor Description
      MorphiaCursor​(Datastore datastore, com.mongodb.Cursor cursor, Mapper mapper, java.lang.Class<T> clazz, EntityCache cache)
      Creates a MorphiaCursor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the underlying cursor.
      protected com.mongodb.DBObject getNext()  
      com.mongodb.ServerAddress getServerAddress()  
      com.mongodb.ServerCursor getServerCursor()  
      boolean hasNext()  
      T next()  
      void remove()  
      java.util.List<T> toList()
      Converts this cursor to a List.
      T tryNext()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • MorphiaCursor

        public MorphiaCursor​(Datastore datastore,
                             com.mongodb.Cursor cursor,
                             Mapper mapper,
                             java.lang.Class<T> clazz,
                             EntityCache cache)
        Creates a MorphiaCursor
        Parameters:
        datastore - the Datastore to use when fetching this reference
        cursor - the Iterator to use
        mapper - the Mapper to use
        clazz - the original type being iterated
        cache - the EntityCache
    • Method Detail

      • toList

        public java.util.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
      • close

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

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

        public T next()
        Specified by:
        next in interface java.util.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

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

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<T>
      • getNext

        protected com.mongodb.DBObject getNext()