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 int
size
Cached 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 void
add(int index, Object element)
boolean
add(Object e)
boolean
addAll(int index, Collection c)
boolean
addAll(Collection c)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection c)
E
get(int index)
protected abstract int
getSize()
Method to return the size of the list.int
indexOf(Object o)
boolean
isEmpty()
protected boolean
isOpen()
Accessor whether the list is open.Iterator<E>
iterator()
int
lastIndexOf(Object o)
ListIterator
listIterator()
ListIterator
listIterator(int index)
E
remove(int index)
boolean
remove(Object o)
boolean
removeAll(Collection c)
boolean
retainAll(Collection c)
protected abstract E
retrieveObjectForIndex(int index)
Accessor to retrieve the object at an index.Object
set(int index, Object element)
int
size()
List
subList(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:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
isEmpty
public boolean isEmpty()
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf
in interfaceList<E>
-
listIterator
public ListIterator listIterator()
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIterator
in 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()
-
-