net.sf.molae.pipe.trafo
Class TransformedList<S,E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by net.sf.molae.pipe.basic.CollectionAsList<E>
              extended by 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

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
TransformedList(List<S> base, TwoWayTransformer<S,E> transformer)
          Constructs a TransformedList object.
 
Method Summary
 void add(int index, E element)
           
 E get(int index)
           
 ListIterator<E> listIterator()
           
 ListIterator<E> listIterator(int index)
           
static
<S,E> TransformedList<S,E>
newInstance(List<S> base, TwoWayTransformer<S,E> transformer)
          Constructs a TransformedList object.
 E remove(int index)
           
 E set(int index, E element)
           
 List<E> subList(int fromIndex, int toIndex)
           
 
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
 
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, indexOf, lastIndexOf, removeRange
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransformedList

public TransformedList(List<S> base,
                       TwoWayTransformer<S,E> transformer)
Constructs a TransformedList object.

Parameters:
base - the underlying collection
transformer - the transformer that maps each element to another one.
Throws:
NullPointerException - if any of the specified objects is null.
Method Detail

newInstance

public static <S,E> TransformedList<S,E> newInstance(List<S> base,
                                                     TwoWayTransformer<S,E> transformer)
Constructs a TransformedList object.

Parameters:
base - the underlying collection
transformer - 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).