Package io.objectbox.query
Class LazyList<E>
java.lang.Object
io.objectbox.query.LazyList<E>
- Type Parameters:
E
- Object type (entity).
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
A thread-safe, unmodifiable
List
that gets Objects from their Box not until they are accessed.
Internally the list is backed by an array of Object IDs.
If the list is set to not cache retrieved Objects, each operation will get the latest version of an Object
from its Box. However, in this mode only a limited set of List
operations,
like get or iterator are supported.
If the list is set to cache retrieved Objects, operations will return a previously fetched version of an Object,
which might not equal the latest version in its Box. However, in this mode almost all List
operations are supported. Note that operations that require the whole list, like contains, will fetch all
Objects in this list from the Box at once.
Note: as Objects are fetched on demand, this list returns a null Object if the Object was removed from its Box after this list was created.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int arg0, Collection<? extends E> arg1) boolean
addAll
(Collection<? extends E> arg0) protected void
void
clear()
boolean
boolean
containsAll
(Collection<?> collection) get
(int location) Gets and returns the Object at the specified position in this list from its Box.int
int
boolean
isEmpty()
boolean
iterator()
int
lastIndexOf
(Object object) listIterator
(int location) void
Loads the remaining entities (if any) that were not loaded before.peek
(int location) Like get but does not load the entity if it was not loaded before.remove
(int location) boolean
boolean
removeAll
(Collection<?> arg0) boolean
retainAll
(Collection<?> arg0) int
size()
subList
(int start, int end) Object[]
toArray()
<T> T[]
toArray
(T[] array) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Method Details
-
loadRemaining
public void loadRemaining()Loads the remaining entities (if any) that were not loaded before. Applies to cached lazy lists only. -
checkCached
protected void checkCached() -
peek
Like get but does not load the entity if it was not loaded before. -
getLoadedCount
public int getLoadedCount() -
isLoadedCompletely
public boolean isLoadedCompletely() -
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
get
Gets and returns the Object at the specified position in this list from its Box. Returns null if the Object was removed from its Box. If this list is caching retrieved Objects, returns the previously fetched version. -
indexOf
-
isEmpty
public boolean isEmpty() -
iterator
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
size
public int size() -
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] array)
-