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
public abstract class AbstractLazyLoadList<E> extends Object implements List<E>
Abstract implementation of a lazy loaded list of (persistent) objects. Needs to be extended to implement theretrieveObjectForIndex()method to retrieve the object at the specified index from whatever datasource is being used, and to implement thegetSize()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
-
-
Field Summary
Fields Modifier and Type Field Description protected intsizeCached size of the list.
-
Constructor Summary
Constructors Constructor Description AbstractLazyLoadList(String cacheType)Constructor for a lazy load list.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Object element)booleanadd(Object e)booleanaddAll(int index, Collection c)booleanaddAll(Collection c)voidclear()booleancontains(Object o)booleancontainsAll(Collection c)Eget(int index)protected abstract intgetSize()Method to return the size of the list.intindexOf(Object o)booleanisEmpty()protected booleanisOpen()Accessor whether the list is open.Iterator<E>iterator()intlastIndexOf(Object o)ListIteratorlistIterator()ListIteratorlistIterator(int index)Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection c)booleanretainAll(Collection c)protected abstract EretrieveObjectForIndex(int index)Accessor to retrieve the object at an index.Objectset(int index, Object element)intsize()ListsubList(int fromIndex, int toIndex)Object[]toArray()Object[]toArray(Object[] 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, toArray
-
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
-
-
-
Constructor Detail
-
AbstractLazyLoadList
public AbstractLazyLoadList(String cacheType)
Constructor for a lazy load list.- Parameters:
cacheType- Type of caching of objects in the list
-
-
Method Detail
-
retrieveObjectForIndex
protected abstract E retrieveObjectForIndex(int index)
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
public boolean add(Object e)
-
addAll
public boolean addAll(Collection c)
-
addAll
public boolean addAll(int index, Collection c)
-
clear
public void clear()
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
isEmpty
public boolean isEmpty()
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
public ListIterator listIterator()
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>
-
remove
public boolean remove(Object o)
-
removeAll
public boolean removeAll(Collection c)
-
retainAll
public boolean retainAll(Collection c)
-
size
public int size()
-
toArray
public Object[] toArray()
-
-