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, unmodifiable list that reads entities lazily once they are accessed. A lazy list can be cached or not. Cached lazy lists store the previously accessed objects to avoid loading entities more than once. Some features of the list are limited to cached lists (e.g. features that require the entire list).Note: this list gives an semiconsitent view on the data at the moment it was created. If you remove objects from their object box after this list was created, this list will null instead of an object. However, if you add objects to their object box after this list was created, this list will not be extended.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
LazyList.LazyIterator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int location, E object)
boolean
add(E object)
boolean
addAll(int arg0, java.util.Collection<? extends E> arg1)
boolean
addAll(java.util.Collection<? extends E> arg0)
protected void
checkCached()
void
clear()
boolean
contains(java.lang.Object object)
boolean
containsAll(java.util.Collection<?> collection)
E
get(int location)
int
getLoadedCount()
int
indexOf(java.lang.Object object)
boolean
isEmpty()
boolean
isLoadedCompletely()
java.util.Iterator<E>
iterator()
int
lastIndexOf(java.lang.Object object)
java.util.ListIterator<E>
listIterator()
java.util.ListIterator<E>
listIterator(int location)
void
loadRemaining()
Loads the remaining entities (if any) that were not loaded before.E
peek(int location)
Like get but does not load the entity if it was not loaded before.E
remove(int location)
boolean
remove(java.lang.Object object)
boolean
removeAll(java.util.Collection<?> arg0)
boolean
retainAll(java.util.Collection<?> arg0)
E
set(int location, E object)
int
size()
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:
addAll
in 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
public E get(int location)
- Specified by:
get
in interfacejava.util.List<E>
- Returns:
- An object for the given ID, or null if the object was already removed from its box (and was not cached before).
-
indexOf
public int indexOf(java.lang.Object object)
- Specified by:
indexOf
in 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:
lastIndexOf
in interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator(int location)
- Specified by:
listIterator
in 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:
subList
in interfacejava.util.List<E>
-
toArray
public java.lang.Object[] toArray()
-
-