Package org.datanucleus.store.query
Class AbstractLazyLoadList<E>
java.lang.Object
org.datanucleus.store.query.AbstractLazyLoadList<E>
- Type Parameters:
E- Type of the element of this list
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>
- Direct Known Subclasses:
AbstractCandidateLazyLoadList
Abstract implementation of a lazy loaded list of (persistent) objects.
Needs to be extended to implement the
retrieveObjectForIndex() method to retrieve the object at the specified index
from whatever datasource is being used, and to implement the getSize() method to return the size of the list.
The "datasource" could be results for a query, or a connection to a datastore, or whatever ... just a source of objects.
TODO Change Localised message numbers to be generic-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classIterator for the elements of the List. -
Field Summary
FieldsModifier and TypeFieldDescriptionMap of object, keyed by the index (0, 1, etc).protected intCached size of the list. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection c) booleanaddAll(Collection c) voidclear()booleanbooleanget(int index) protected abstract intgetSize()Method to return the size of the list.intbooleanisEmpty()protected booleanisOpen()Accessor whether the list is open.iterator()intlistIterator(int index) remove(int index) booleanbooleanbooleanprotected abstract EretrieveObjectForIndex(int index) Accessor to retrieve the object at an index.intsize()subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Field Details
-
itemsByIndex
Map of object, keyed by the index (0, 1, etc). -
size
protected int sizeCached size of the list. -1 when not known.
-
-
Constructor Details
-
AbstractLazyLoadList
Constructor for a lazy load list.- Parameters:
cacheType- Type of caching of objects in the list
-
-
Method Details
-
retrieveObjectForIndex
Accessor to retrieve the object at an index. Is only called if the object is not currently cached.- Parameters:
index- The list index- Returns:
- The object
-
getSize
protected abstract int getSize()Method to return the size of the list.- Returns:
- The size
-
isOpen
protected boolean isOpen()Accessor whether the list is open. Always open in this implementation but can be overridden if you want to allow closure.- Returns:
- Whether it is open.
-
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
get
-
indexOf
-
isEmpty
public boolean isEmpty() -
iterator
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
size
public int size() -
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a)
-