net.sf.molae.pipe.trafo
Class TransformedList<S,E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
net.sf.molae.pipe.basic.CollectionAsList<E>
net.sf.molae.pipe.trafo.TransformedList<S,E>
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, List<E>
public final class TransformedList<S,E>
- extends CollectionAsList<E>
Provides a different view to an existing list by
transforming each element.
- See Also:
TransformedCollection
Methods inherited from class net.sf.molae.pipe.basic.CollectionAsList |
add, addAll, clear, contains, containsAll, getBase, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString |
TransformedList
public TransformedList(List<S> base,
TwoWayTransformer<S,E> transformer)
- Constructs a TransformedList object.
- Parameters:
base
- the underlying collectiontransformer
- the transformer that maps each element to another one.
- Throws:
NullPointerException
- if any of the specified objects is
null
.
newInstance
public static <S,E> TransformedList<S,E> newInstance(List<S> base,
TwoWayTransformer<S,E> transformer)
- Constructs a TransformedList object.
- Parameters:
base
- the underlying collectiontransformer
- the transformer that maps each element to another one.
- Throws:
NullPointerException
- if any of the specified objects is
null
.- Since:
- 2.0
get
public E get(int index)
- Specified by:
get
in interface List<E>
- Specified by:
get
in class AbstractList<E>
- Throws:
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())
set
public E set(int index,
E element)
- Specified by:
set
in interface List<E>
- Overrides:
set
in class AbstractList<E>
- Throws:
UnsupportedOperationException
- depending on the base collection
and transformer
ClassCastException
- depending on the base collection
and transformer
IllegalArgumentException
- depending on the base collection
and transformer
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())
add
public void add(int index,
E element)
- Specified by:
add
in interface List<E>
- Overrides:
add
in class AbstractList<E>
- Throws:
UnsupportedOperationException
- depending on the base collection
and transformer
ClassCastException
- depending on the base collection
and transformer
IllegalArgumentException
- depending on the base collection
and transformer
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size())
remove
public E remove(int index)
- Specified by:
remove
in interface List<E>
- Overrides:
remove
in class AbstractList<E>
- Throws:
UnsupportedOperationException
- depending on the base collection
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIterator
in interface List<E>
- Overrides:
listIterator
in class AbstractList<E>
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIterator
in interface List<E>
- Overrides:
listIterator
in class AbstractList<E>
- Throws:
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size())
subList
public List<E> subList(int fromIndex,
int toIndex)
- Specified by:
subList
in interface List<E>
- Overrides:
subList
in class AbstractList<E>
- Throws:
IndexOutOfBoundsException
- for an illegal endpoint index value
(fromIndex < 0 || toIndex > size || fromIndex > toIndex).