Package org.springframework.util
Class AutoPopulatingList<E>
java.lang.Object
org.springframework.util.AutoPopulatingList<E>
- Type Parameters:
E- the element type
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,List<E>
Simple
List wrapper class that allows for elements to be
automatically populated as they are requested. This is particularly
useful for data binding to Lists, allowing for elements
to be created and added to the List in a "just in time" fashion.
Note: This class is not thread-safe. To create a thread-safe version,
use the Collections.synchronizedList(java.util.List<T>) utility methods.
Inspired by LazyList from Commons Collections.
- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFactory interface for creating elements for an index-based access data structure such as aList.static classException to be thrown from ElementFactory. -
Constructor Summary
ConstructorsConstructorDescriptionAutoPopulatingList(Class<? extends E> elementClass) Creates a newAutoPopulatingListthat is backed by a standardArrayListand adds new instances of the suppliedelement Classto the backingListon demand.AutoPopulatingList(List<E> backingList, Class<? extends E> elementClass) Creates a newAutoPopulatingListthat is backed by the suppliedListand adds new instances of the suppliedelement Classto the backingListon demand.AutoPopulatingList(List<E> backingList, AutoPopulatingList.ElementFactory<E> elementFactory) Creates a newAutoPopulatingListthat is backed by the suppliedListand creates new elements on demand using the suppliedAutoPopulatingList.ElementFactory.AutoPopulatingList(AutoPopulatingList.ElementFactory<E> elementFactory) Creates a newAutoPopulatingListthat is backed by a standardArrayListand creates new elements on demand using the suppliedAutoPopulatingList.ElementFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleanget(int index) Get the element at the supplied index, creating it if there is no element at that index.inthashCode()intbooleanisEmpty()iterator()intlistIterator(int index) remove(int index) booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Constructor Details
-
AutoPopulatingList
Creates a newAutoPopulatingListthat is backed by a standardArrayListand adds new instances of the suppliedelement Classto the backingListon demand. -
AutoPopulatingList
Creates a newAutoPopulatingListthat is backed by the suppliedListand adds new instances of the suppliedelement Classto the backingListon demand. -
AutoPopulatingList
Creates a newAutoPopulatingListthat is backed by a standardArrayListand creates new elements on demand using the suppliedAutoPopulatingList.ElementFactory. -
AutoPopulatingList
Creates a newAutoPopulatingListthat is backed by the suppliedListand creates new elements on demand using the suppliedAutoPopulatingList.ElementFactory.
-
-
Method Details
-
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
get
Get the element at the supplied index, creating it if there is no element at that index. -
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) -
equals
-
hashCode
public int hashCode()
-