public abstract class ConditionalIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>
Constructor and Description |
---|
ConditionalIterator(java.util.Iterator<T> source)
Constructs a ConditionalIterator with a source
Iterator of type T.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Whether there are more elements to be fetched from this Iterator.
|
protected abstract boolean |
isAllowed(T element)
Subclasses implement this method to determine if an element is allowed to
be returned.
|
T |
next()
Fetches the next element in the Iterator that matches
the condition implemented by subclasses' isAllowed method.
|
void |
remove()
Removes the currently selected element in the Iterator.
|
public ConditionalIterator(java.util.Iterator<T> source)
source
- an Iterator of type T to test conditions onpublic boolean hasNext()
hasNext
in interface java.util.Iterator<T>
public void remove()
remove
in interface java.util.Iterator<T>
public T next()
next
in interface java.util.Iterator<T>
protected abstract boolean isAllowed(T element)
element
- Iterator element being tested for allowal