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 class
Iterator for the elements of the List. -
Field Summary
FieldsModifier and TypeFieldDescriptionMap of object, keyed by the index (0, 1, etc).protected int
Cached size of the list. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection c) boolean
addAll
(Collection c) void
clear()
boolean
boolean
get
(int index) protected abstract int
getSize()
Method to return the size of the list.int
boolean
isEmpty()
protected boolean
isOpen()
Accessor whether the list is open.iterator()
int
listIterator
(int index) remove
(int index) boolean
boolean
boolean
protected abstract E
retrieveObjectForIndex
(int index) Accessor to retrieve the object at an index.int
size()
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, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods 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:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
get
-
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[] a)
-