Package org.greenrobot.greendao.query
Class LazyList<E>
- java.lang.Object
-
- org.greenrobot.greendao.query.LazyList<E>
-
- Type Parameters:
E- Entity type.
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,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>, java.io.CloseableA thread-safe, unmodifiable list that reads entities once they are accessed from an underlying database cursor. Make sure to close the list once you are done with it. The lazy list can be cached or not. Cached lazy lists store the entities in memory 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). Cached lists close the cursor automatically once you queried all entities. However, to avoid leaked cursors, you should not rely on this behavior: if an exception occurs before the entire list is read, you should close the lazy list (and thus the underlying cursor) on your own to be on the safe side.
-
-
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()voidclose()booleancontains(java.lang.Object object)booleancontainsAll(java.util.Collection<?> collection)Eget(int location)intgetLoadedCount()intindexOf(java.lang.Object object)booleanisClosed()booleanisEmpty()booleanisLoadedCompletely()java.util.Iterator<E>iterator()intlastIndexOf(java.lang.Object object)CloseableListIterator<E>listIterator()java.util.ListIterator<E>listIterator(int location)CloseableListIterator<E>listIteratorAutoClose()Closes this list's cursor once the iterator is fully iterated through.protected EloadEntity(int location)Lock must be locked when entering this method.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.
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
isClosed
public boolean isClosed()
-
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)
-
loadEntity
protected E loadEntity(int location)
Lock must be locked when entering this method.
-
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 CloseableListIterator<E> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<E>
-
listIteratorAutoClose
public CloseableListIterator<E> listIteratorAutoClose()
Closes this list's cursor once the iterator is fully iterated through.
-
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()
-
-