public class TransformedList extends TransformedCollection implements java.util.List
List
to transform objects that are added.
The add and set methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.
This class is Serializable from Commons Collections 3.1.
Modifier and Type | Class and Description |
---|---|
protected class |
TransformedList.TransformedListIterator
Inner class Iterator for the TransformedList
|
transformer
collection
Modifier | Constructor and Description |
---|---|
protected |
TransformedList(java.util.List list,
Transformer transformer)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
java.lang.Object object) |
boolean |
addAll(int index,
java.util.Collection coll) |
static java.util.List |
decorate(java.util.List list,
Transformer transformer)
Factory method to create a transforming list.
|
java.lang.Object |
get(int index) |
protected java.util.List |
getList()
Gets the decorated list.
|
int |
indexOf(java.lang.Object object) |
int |
lastIndexOf(java.lang.Object object) |
java.util.ListIterator |
listIterator() |
java.util.ListIterator |
listIterator(int i) |
java.lang.Object |
remove(int index) |
java.lang.Object |
set(int index,
java.lang.Object object) |
java.util.List |
subList(int fromIndex,
int toIndex) |
add, addAll, decorate, transform, transform
clear, contains, containsAll, equals, getCollection, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
protected TransformedList(java.util.List list, Transformer transformer)
If there are any elements already in the list being decorated, they are NOT transformed.
list
- the list to decorate, must not be nulltransformer
- the transformer to use for conversion, must not be nulljava.lang.IllegalArgumentException
- if list or transformer is nullpublic static java.util.List decorate(java.util.List list, Transformer transformer)
If there are any elements already in the list being decorated, they are NOT transformed.
list
- the list to decorate, must not be nulltransformer
- the transformer to use for conversion, must not be nulljava.lang.IllegalArgumentException
- if list or transformer is nullprotected java.util.List getList()
public java.lang.Object get(int index)
get
in interface java.util.List
public int indexOf(java.lang.Object object)
indexOf
in interface java.util.List
public int lastIndexOf(java.lang.Object object)
lastIndexOf
in interface java.util.List
public java.lang.Object remove(int index)
remove
in interface java.util.List
public void add(int index, java.lang.Object object)
add
in interface java.util.List
public boolean addAll(int index, java.util.Collection coll)
addAll
in interface java.util.List
public java.util.ListIterator listIterator()
listIterator
in interface java.util.List
public java.util.ListIterator listIterator(int i)
listIterator
in interface java.util.List
public java.lang.Object set(int index, java.lang.Object object)
set
in interface java.util.List
public java.util.List subList(int fromIndex, int toIndex)
subList
in interface java.util.List
Copyright © 2001-2024 Apache Software Foundation. All Rights Reserved.