E - the type of objects returned by the iteratorpublic abstract static class Iterators.Filter<E> extends Object implements Iterator<E>
Iterators.Filter filters the stream of objects
returned by another iterator by subjecting them to an acceptance
test. Instances are constructed with a specified iterator to be
filtered; this filter is saved in this class and should not be
accessed by other methods. Concrete subclasses must implement
accept(Object), which determines which of the elements
produced by the containediterator are returned.| Constructor and Description |
|---|
Iterators.Filter(Iterator<? extends E> iterator)
Construct a filtered iterator from the specified iterator.
|
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
accept(E x)
Returns
true for objects returned by the contained
iterator that should be returned by this iterator. |
boolean |
hasNext()
Returns
true if calls to next() will
return a value. |
E |
next()
Returns the next value from the contained iterator that is accepted.
|
void |
remove()
This operation is not supported.
|
public abstract boolean accept(E x)
true for objects returned by the contained
iterator that should be returned by this iterator.x - Object to test.true if this object should be returned by
this iterator.public boolean hasNext()
true if calls to next() will
return a value.
Implementation note: This iterator stores the next
element in a local variable after calls to this method. Calls to
next() remove this reference.
public E next()
accept(Object).next in interface Iterator<E>NoSuchElementException - If there are no more elements in
the underlying iterator that pass the acceptance test.public void remove()
Implementation Note: Because calls to hasNext() must iterate over the contained iterator to find
the next acceptable object to return, it is not guaranteed that
the last element returned by this iterator is the same as the
last element returned by the underlying iterator. Thus the
underlying iterator can't be used to do the removal without
tripping the fail-fast behavior of Iterator.
remove in interface Iterator<E>UnsupportedOperationException - Always.Copyright © 2016 Alias-i, Inc.. All rights reserved.