net.sf.mmm.util.collection.base
Class FilteredIterator<E>
java.lang.Object
net.sf.mmm.util.collection.base.AbstractIterator<E>
net.sf.mmm.util.collection.base.FilteredIterator<E>
- Type Parameters:
E - is the generic type of the iterated elements.
- All Implemented Interfaces:
- Iterator<E>
public class FilteredIterator<E>
- extends AbstractIterator<E>
This is an implementation of an Iterator that adapts another
Iterator but only iterates the elements that are
accepted by a given Filter.
ATTENTION:
According to the design of the Iterator interface, it is NOT possible
to implement the AbstractIterator.remove() method properly here. The method
AbstractIterator.hasNext() has to step forward in the adapted Iterator and a
call of AbstractIterator.remove() would cause unintended and unpredictable results
after AbstractIterator.hasNext() has been called. To prevent damage AbstractIterator.remove()
will always throw an UnsupportedOperationException.
- Since:
- 2.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
|
Method Summary |
protected E |
findNext()
This method tries to find the next element. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
delegate
private final Iterator<E> delegate
- The actual iterator instance to adapt.
filter
private final Filter<E> filter
- See Also:
findNext()
FilteredIterator
public FilteredIterator(Iterator<E> delegate,
Filter<E> filter)
- The constructor.
- Parameters:
delegate - is the Iterator to adapt.filter - is the Filter that filters the iterated elements.
findNext
protected E findNext()
- This method tries to find the
next element.
- Specified by:
findNext in class AbstractIterator<E>
- Returns:
- the next element or
null if done.
Copyright © 2001-2010 mmm-Team. All Rights Reserved.