|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.AutoPopulatingList<E>
public class AutoPopulatingList<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
utility methods.
Inspired by LazyList
from Commons Collections.
Nested Class Summary | |
---|---|
static interface |
AutoPopulatingList.ElementFactory<E>
Factory interface for creating elements for an index-based access data structure such as a List . |
static class |
AutoPopulatingList.ElementInstantiationException
Exception to be thrown from ElementFactory. |
private static class |
AutoPopulatingList.ReflectiveElementFactory<E>
Reflective implementation of the ElementFactory interface, using Class.newInstance() on a given element class. |
Field Summary | |
---|---|
private java.util.List<E> |
backingList
The List that all operations are eventually delegated to. |
private AutoPopulatingList.ElementFactory<E> |
elementFactory
The AutoPopulatingList.ElementFactory to use to create new List elements
on demand. |
Constructor Summary | |
---|---|
AutoPopulatingList(AutoPopulatingList.ElementFactory<E> elementFactory)
Creates a new AutoPopulatingList that is backed by a standard
ArrayList and creates new elements on demand using the supplied AutoPopulatingList.ElementFactory . |
|
AutoPopulatingList(java.lang.Class<? extends E> elementClass)
Creates a new AutoPopulatingList that is backed by a standard
ArrayList and adds new instances of the supplied element Class
to the backing List on demand. |
|
AutoPopulatingList(java.util.List<E> backingList,
AutoPopulatingList.ElementFactory<E> elementFactory)
Creates a new AutoPopulatingList that is backed by the supplied List
and creates new elements on demand using the supplied AutoPopulatingList.ElementFactory . |
|
AutoPopulatingList(java.util.List<E> backingList,
java.lang.Class<? extends E> elementClass)
Creates a new AutoPopulatingList that is backed by the supplied List
and adds new instances of the supplied element Class to the backing
List on demand. |
Method Summary | ||
---|---|---|
boolean |
add(E o)
|
|
void |
add(int index,
E element)
|
|
boolean |
addAll(java.util.Collection<? extends E> c)
|
|
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
|
|
void |
clear()
|
|
boolean |
contains(java.lang.Object o)
|
|
boolean |
containsAll(java.util.Collection c)
|
|
boolean |
equals(java.lang.Object other)
|
|
E |
get(int index)
Get the element at the supplied index, creating it if there is no element at that index. |
|
int |
hashCode()
|
|
int |
indexOf(java.lang.Object o)
|
|
boolean |
isEmpty()
|
|
java.util.Iterator<E> |
iterator()
|
|
int |
lastIndexOf(java.lang.Object o)
|
|
java.util.ListIterator<E> |
listIterator()
|
|
java.util.ListIterator<E> |
listIterator(int index)
|
|
E |
remove(int index)
|
|
boolean |
remove(java.lang.Object o)
|
|
boolean |
removeAll(java.util.Collection<?> c)
|
|
boolean |
retainAll(java.util.Collection<?> c)
|
|
E |
set(int index,
E element)
|
|
int |
size()
|
|
java.util.List<E> |
subList(int fromIndex,
int toIndex)
|
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] a)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.util.List<E> backingList
List
that all operations are eventually delegated to.
private final AutoPopulatingList.ElementFactory<E> elementFactory
AutoPopulatingList.ElementFactory
to use to create new List
elements
on demand.
Constructor Detail |
---|
public AutoPopulatingList(java.lang.Class<? extends E> elementClass)
AutoPopulatingList
that is backed by a standard
ArrayList
and adds new instances of the supplied element Class
to the backing List
on demand.
public AutoPopulatingList(java.util.List<E> backingList, java.lang.Class<? extends E> elementClass)
AutoPopulatingList
that is backed by the supplied List
and adds new instances of the supplied element Class
to the backing
List
on demand.
public AutoPopulatingList(AutoPopulatingList.ElementFactory<E> elementFactory)
AutoPopulatingList
that is backed by a standard
ArrayList
and creates new elements on demand using the supplied AutoPopulatingList.ElementFactory
.
public AutoPopulatingList(java.util.List<E> backingList, AutoPopulatingList.ElementFactory<E> elementFactory)
AutoPopulatingList
that is backed by the supplied List
and creates new elements on demand using the supplied AutoPopulatingList.ElementFactory
.
Method Detail |
---|
public void add(int index, E element)
add
in interface java.util.List<E>
public boolean add(E o)
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
public boolean addAll(int index, java.util.Collection<? extends E> c)
addAll
in interface java.util.List<E>
public void clear()
clear
in interface java.util.Collection<E>
clear
in interface java.util.List<E>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
contains
in interface java.util.List<E>
public boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection<E>
containsAll
in interface java.util.List<E>
public E get(int index)
get
in interface java.util.List<E>
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<E>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
isEmpty
in interface java.util.List<E>
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in interface java.util.List<E>
public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<E>
public java.util.ListIterator<E> listIterator()
listIterator
in interface java.util.List<E>
public java.util.ListIterator<E> listIterator(int index)
listIterator
in interface java.util.List<E>
public E remove(int index)
remove
in interface java.util.List<E>
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
remove
in interface java.util.List<E>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.List<E>
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.List<E>
public E set(int index, E element)
set
in interface java.util.List<E>
public int size()
size
in interface java.util.Collection<E>
size
in interface java.util.List<E>
public java.util.List<E> subList(int fromIndex, int toIndex)
subList
in interface java.util.List<E>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
public boolean equals(java.lang.Object other)
equals
in interface java.util.Collection<E>
equals
in interface java.util.List<E>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.List<E>
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |