Package io.objectbox.query
Class LazyList<E>
- java.lang.Object
-
- io.objectbox.query.LazyList<E>
-
- Type Parameters:
E- Object type (entity).
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.List<E>
public class LazyList<E> extends java.lang.Object implements java.util.List<E>A thread-safe, unmodifiableListthat 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
Listoperations, 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
Listoperations 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 Modifier and Type Class Description protected classLazyList.LazyIterator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int location, E object)booleanadd(E object)booleanaddAll(int arg0, java.util.Collection<? extends E> arg1)booleanaddAll(java.util.Collection<? extends E> arg0)protected voidcheckCached()voidclear()booleancontains(java.lang.Object object)booleancontainsAll(java.util.Collection<?> collection)Eget(int location)Gets and returns the Object at the specified position in this list from its Box.intgetLoadedCount()intindexOf(java.lang.Object object)booleanisEmpty()booleanisLoadedCompletely()java.util.Iterator<E>iterator()intlastIndexOf(java.lang.Object object)java.util.ListIterator<E>listIterator()java.util.ListIterator<E>listIterator(int location)voidloadRemaining()Loads the remaining entities (if any) that were not loaded before.Epeek(int location)Like get but does not load the entity if it was not loaded before.Eremove(int location)booleanremove(java.lang.Object object)booleanremoveAll(java.util.Collection<?> arg0)booleanretainAll(java.util.Collection<?> arg0)Eset(int location, E object)intsize()java.util.List<E>subList(int start, int end)java.lang.Object[]toArray()<T> T[]toArray(T[] array)
-
-
-
Method Detail
-
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
public E peek(int location)
Like get but does not load the entity if it was not loaded before.
-
getLoadedCount
public int getLoadedCount()
-
isLoadedCompletely
public boolean isLoadedCompletely()
-
add
public boolean add(E object)
-
addAll
public boolean addAll(java.util.Collection<? extends E> arg0)
-
addAll
public boolean addAll(int arg0, java.util.Collection<? extends E> arg1)- Specified by:
addAllin interfacejava.util.List<E>
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object object)
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
-
get
@Nullable public E get(int location)
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.- Specified by:
getin interfacejava.util.List<E>
-
indexOf
public int indexOf(java.lang.Object object)
- Specified by:
indexOfin interfacejava.util.List<E>
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<E> iterator()
-
lastIndexOf
public int lastIndexOf(java.lang.Object object)
- Specified by:
lastIndexOfin interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator(int location)
- Specified by:
listIteratorin interfacejava.util.List<E>
-
remove
public boolean remove(java.lang.Object object)
-
removeAll
public boolean removeAll(java.util.Collection<?> arg0)
-
retainAll
public boolean retainAll(java.util.Collection<?> arg0)
-
size
public int size()
-
subList
public java.util.List<E> subList(int start, int end)
- Specified by:
subListin interfacejava.util.List<E>
-
toArray
public java.lang.Object[] toArray()
-
-