org.schmant.support.util
Class FlatteningList<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<T>
org.schmant.support.util.FlatteningList<T>
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess
public class FlatteningList<T>
- extends ArrayList<T>
This is a list of object that flattens all collections and arrays added to.
All objects contained in an added array or collection are extracted and added
to the list at the place of the array or collection. Objects that themselves
are arrays or lists are flattened again, recursively.
This list is often used to contain values for tasks that have interpreted
properties that can have several values.
Some script language implementations have their own array types. A
ScriptExecutor can register a
FlatteningListDecorator with the
registerDecorator(FlatteningListDecorator) method to make the
FlatteningList able to flatten its array types too.
- Since:
- 1.0
- Author:
- Karl Gustafsson
- See Also:
- Serialized Form
| Methods inherited from class java.util.ArrayList |
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, size, toArray, toArray, trimToSize |
FlatteningList
public FlatteningList()
FlatteningList
public FlatteningList(int capacity)
registerDecorator
public static void registerDecorator(FlatteningListDecorator d)
- Register a decorator.
- Parameters:
d - The decorator
add
public boolean add(T o)
- Specified by:
add in interface Collection<T>- Specified by:
add in interface List<T>- Overrides:
add in class ArrayList<T>
add
public void add(int index,
T o)
throws UnsupportedOperationException
- Specified by:
add in interface List<T>- Overrides:
add in class ArrayList<T>
- Throws:
UnsupportedOperationException
add
public void add(Object o,
ObjectTransformer<T> transformer)
- Add one or several objects. Each added object is transformed into the
target type by the supplied transformer.
- Parameters:
o - The object or objects to add.transformer - The transformer used to transform each added object
into the target type.
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAll in interface Collection<T>- Specified by:
addAll in interface List<T>- Overrides:
addAll in class ArrayList<T>
add
public void add(int index,
Object o,
ObjectTransformer<T> transformer)
addAll
public boolean addAll(int index,
Collection<? extends T> c)
throws UnsupportedOperationException
- Specified by:
addAll in interface List<T>- Overrides:
addAll in class ArrayList<T>
- Throws:
UnsupportedOperationException - Always!
set
public T set(int index,
T o)
throws UnsupportedOperationException
- Specified by:
set in interface List<T>- Overrides:
set in class ArrayList<T>
- Throws:
UnsupportedOperationException - Always!