ch.elca.el4j.util.collections.impl
Class DefaultFilteredList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<T>
              extended by ch.elca.el4j.util.collections.impl.DefaultFilteredList<T>
Type Parameters:
T - the element type
All Implemented Interfaces:
ExtendedList<T>, FilteredList<T>, Iterable<T>, Collection<T>, List<T>

public class DefaultFilteredList<T>
extends AbstractSequentialList<T>
implements FilteredList<T>

Default Implementation for FilteredList.

This class is not thread safe.

Author:
Adrian Moos (AMS)
File-location:
DefaultFilteredList
Last check-in date:
2009-08-04 14:25:40 +0200 (Di, 04. Aug 2009) by swismer for revision 3874

Nested Class Summary
protected  class DefaultFilteredList.Iter
          Iterator class.
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DefaultFilteredList(List<? extends T> backing, Filter<? super T> filter)
          Constructor.
 
Method Summary
 boolean add(T t)
           
 FilteredList<T> filtered(Filter<? super T> filter)
          Convenience method returning a filtered view on this collection.
 Iterator<T> iterator()
          Returns an iterator over the accepted elements.
 ListIterator<T> listIterator()
          
 ListIterator<T> listIterator(int index)
          
 ListIterator<T> listIterator(ListIterator<? extends T> location)
          Returns a BiDiIterator for this collection pointing at the place corresponding to location.
<O> TransformedList<T,O>
mapped(Function<? super T,O> function)
          Convenience method returning a TransformedList view to this list.
 int size()
          
 T[] toArray(Class<T> c)
          
 
Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, remove, set
 
Methods inherited from class java.util.AbstractList
clear, equals, hashCode, indexOf, lastIndexOf, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, lastIndexOf, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 

Constructor Detail

DefaultFilteredList

public DefaultFilteredList(List<? extends T> backing,
                           Filter<? super T> filter)
Constructor.

Parameters:
backing - the backing List
filter - the filter to apply
Method Detail

toArray

public T[] toArray(Class<T> c)

Specified by:
toArray in interface ExtendedList<T>
Parameters:
c - the element type for the new array
Returns:
an new array containing this list's contents

add

public boolean add(T t)
Specified by:
add in interface Collection<T>
Specified by:
add in interface List<T>
Overrides:
add in class AbstractList<T>
Throws:
UnsupportedOperationException

iterator

public Iterator<T> iterator()
Returns an iterator over the accepted elements. The iterator is fail-fast iff the backing list's iterator is.

Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface List<T>
Overrides:
iterator in class AbstractSequentialList<T>

listIterator

public ListIterator<T> listIterator()

Specified by:
listIterator in interface List<T>
Overrides:
listIterator in class AbstractList<T>

listIterator

public ListIterator<T> listIterator(int index)

Specified by:
listIterator in interface List<T>
Specified by:
listIterator in class AbstractSequentialList<T>

listIterator

public ListIterator<T> listIterator(ListIterator<? extends T> location)
Returns a BiDiIterator for this collection pointing at the place corresponding to location.

Specified by:
listIterator in interface FilteredList<T>
Parameters:
location - An iterator for the backing collection. This reference may be captured, i.e. it shouldn't be be used in client code afterwards.
Returns:
The iterator

size

public int size()

Specified by:
size in interface Collection<T>
Specified by:
size in interface List<T>
Specified by:
size in class AbstractCollection<T>

filtered

public FilteredList<T> filtered(Filter<? super T> filter)
Convenience method returning a filtered view on this collection.

Specified by:
filtered in interface ExtendedList<T>
Parameters:
filter - the filter deciding which elements are included

mapped

public <O> TransformedList<T,O> mapped(Function<? super T,O> function)
Convenience method returning a TransformedList view to this list.

Specified by:
mapped in interface ExtendedList<T>
Parameters:
function - the transformation function to apply to each element
Returns:
see above


Copyright © 2005-2011 ELCA. All Rights Reserved.