Package dev.morphia.query.internal
Class MorphiaKeyCursor<T>
- java.lang.Object
-
- dev.morphia.query.internal.MorphiaKeyCursor<T>
-
- Type Parameters:
T- the entity type
- All Implemented Interfaces:
com.mongodb.client.MongoCursor<Key<T>>,java.io.Closeable,java.lang.AutoCloseable,java.util.Iterator<Key<T>>
public class MorphiaKeyCursor<T> extends java.lang.Object implements com.mongodb.client.MongoCursor<Key<T>>
Defines an Iterator across the Key values for a given type.
-
-
Constructor Summary
Constructors Constructor Description MorphiaKeyCursor(Datastore datastore, com.mongodb.Cursor cursor, Mapper mapper, java.lang.Class<T> clazz, java.lang.String collection)Create
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying cursor.com.mongodb.ServerAddressgetServerAddress()com.mongodb.ServerCursorgetServerCursor()booleanhasNext()Key<T>next()voidremove()java.util.List<Key<T>>toList()Converts this cursor to a List.Key<T>tryNext()
-
-
-
Constructor Detail
-
MorphiaKeyCursor
public MorphiaKeyCursor(Datastore datastore, com.mongodb.Cursor cursor, Mapper mapper, java.lang.Class<T> clazz, java.lang.String collection)
Create- Parameters:
datastore- the Datastore to use when fetching this referencecursor- the cursor to usemapper- the Mapper to useclazz- the original type being iteratedcollection- the mongodb collection
-
-
Method Detail
-
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()
-
tryNext
public Key<T> tryNext()
- Specified by:
tryNextin interfacecom.mongodb.client.MongoCursor<T>
-
toList
public java.util.List<Key<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
-
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>
-
-