Package dev.morphia.query.internal
Class MorphiaCursor<T>
- java.lang.Object
-
- dev.morphia.query.internal.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 voidclose()Closes the underlying cursor.protected com.mongodb.DBObjectgetNext()com.mongodb.ServerAddressgetServerAddress()com.mongodb.ServerCursorgetServerCursor()booleanhasNext()Tnext()voidremove()java.util.List<T>toList()Converts this cursor to a List.TtryNext()
-
-
-
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 referencecursor- the Iterator to usemapper- the Mapper to useclazz- the original type being iteratedcache- 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacecom.mongodb.client.MongoCursor<T>
-
hasNext
public boolean hasNext()
-
next
public T next()
-
getServerCursor
public com.mongodb.ServerCursor getServerCursor()
- Specified by:
getServerCursorin interfacecom.mongodb.client.MongoCursor<T>
-
getServerAddress
public com.mongodb.ServerAddress getServerAddress()
- Specified by:
getServerAddressin interfacecom.mongodb.client.MongoCursor<T>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<T>
-
getNext
protected com.mongodb.DBObject getNext()
-
-