Class AbstractFilteredIterator<E>
- java.lang.Object
-
- com.globalmentor.collections.iterators.AbstractPrimedIterator<E>
-
- com.globalmentor.collections.iterators.AbstractFilteredIterator<E>
-
- Type Parameters:
E
- The type of element returned by the iterator.
- All Implemented Interfaces:
java.util.Iterator<E>
- Direct Known Subclasses:
FilteredIterator
public abstract class AbstractFilteredIterator<E> extends AbstractPrimedIterator<E>
Abstract implementation of an iterator that filters an existing iterator.This version does not support
AbstractPrimedIterator.remove()
.This version releases the decorated iterator when iteration is finished.
This class is not thread safe.
- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description AbstractFilteredIterator(java.util.Iterator<E> iterator)
Decorated iterator constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
isPass(E element)
Indicates whether the given element is included when filtering.protected E
primeNext()
Returns the next available element for the iterator.-
Methods inherited from class com.globalmentor.collections.iterators.AbstractPrimedIterator
hasNext, next, remove
-
-
-
-
Constructor Detail
-
AbstractFilteredIterator
public AbstractFilteredIterator(java.util.Iterator<E> iterator)
Decorated iterator constructor.- Parameters:
iterator
- The decorated iterator to be filtered.- Throws:
java.lang.NullPointerException
- if the given iterator isnull
.
-
-
Method Detail
-
primeNext
protected final E primeNext()
Returns the next available element for the iterator. The value returned by this method will be returned by the next call toAbstractPrimedIterator.next
. The implementation guarantees that this method will not be called again afternull
is returned.- Specified by:
primeNext
in classAbstractPrimedIterator<E>
- Returns:
- The next primed value for the iterator, or
null
if there are no further values. - See Also:
isPass(Object)
-
isPass
protected abstract boolean isPass(E element)
Indicates whether the given element is included when filtering.- Parameters:
element
- The element in the filtered iterator.- Returns:
true
if the element should be included, ornull
if it should be filtered out.
-
-