T - the type of the elementspublic class FilteringIterator<T> extends AdaptingIterator<T,T>
Note that Iterator.remove() only works as long as
Iterator.hasNext() was not called to determine if there are
further elements. The reason for that is, that in order to filter elements
of the parent iterator Iterator.next() has to be called to check
weather any further element is valid against the used FilteringIterator.Filter.
This call to Iterator.next() causes the parent Iterator to switch
to the next element, meaning that after that the remove()
method would delete a different element. To avoid that this Iterator
throws an IllegalStateException in such cases. If the parent
Iterator does not support remove() at all an
UnsupportedOperationException is thrown.
This implementation is based on the AdaptingIterator to avoid
duplication of the filtering functionality also needed if an adapter can not
convert a specific value of one type to an other.
| Modifier and Type | Class and Description |
|---|---|
static interface |
FilteringIterator.Filter<T>
Interface used by the
FilteringIterator to check if an element
of the parent Iterator should be filtered or not. |
AdaptingIterator.Adapter<T,A>| Constructor and Description |
|---|
FilteringIterator(Iterator<T> iterator,
FilteringIterator.Filter<T> filter,
Class<T> type) |
Copyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.