Class FilterIterator
java.lang.Object
org.apache.commons.collections.iterators.FilterIterator
- All Implemented Interfaces:
Iterator
- Direct Known Subclasses:
UniqueFilterIterator
Deprecated.
Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
Decorates another
Iterator using a predicate to filter elements.
This iterator decorates the underlying iterator, only allowing through
those elements that match the specified Predicate.
- Since:
- Commons Collections 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Constructs a newFilterIteratorthat will not function untilsetIteratoris invoked.FilterIterator(Iterator iterator) Deprecated.Constructs a newFilterIteratorthat will not function untilsetPredicateis invoked.FilterIterator(Iterator iterator, Predicate predicate) Deprecated.Constructs a newFilterIteratorthat will use the given iterator and predicate. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Gets the iterator this iterator is using.Deprecated.Gets the predicate this iterator is using.booleanhasNext()Deprecated.Returns true if the underlying iterator contains an object that matches the predicate.next()Deprecated.Returns the next object that matches the predicate.voidremove()Deprecated.Removes from the underlying collection of the base iterator the last element returned by this iterator.voidsetIterator(Iterator iterator) Deprecated.Sets the iterator for this iterator to use.voidsetPredicate(Predicate predicate) Deprecated.Sets the predicate this the iterator to use.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
FilterIterator
public FilterIterator()Deprecated.Constructs a newFilterIteratorthat will not function untilsetIteratoris invoked. -
FilterIterator
Deprecated.Constructs a newFilterIteratorthat will not function untilsetPredicateis invoked.- Parameters:
iterator- the iterator to use
-
FilterIterator
Deprecated.Constructs a newFilterIteratorthat will use the given iterator and predicate.- Parameters:
iterator- the iterator to usepredicate- the predicate to use
-
-
Method Details
-
hasNext
public boolean hasNext()Deprecated.Returns true if the underlying iterator contains an object that matches the predicate.- Specified by:
hasNextin interfaceIterator- Returns:
- true if there is another object that matches the predicate
- Throws:
NullPointerException- if either the iterator or predicate are null
-
next
Deprecated.Returns the next object that matches the predicate.- Specified by:
nextin interfaceIterator- Returns:
- the next object which matches the given predicate
- Throws:
NullPointerException- if either the iterator or predicate are nullNoSuchElementException- if there are no more elements that match the predicate
-
remove
public void remove()Deprecated.Removes from the underlying collection of the base iterator the last element returned by this iterator. This method can only be called ifnext()was called, but not afterhasNext(), because thehasNext()call changes the base iterator.- Specified by:
removein interfaceIterator- Throws:
IllegalStateException- ifhasNext()has already been called.
-
getIterator
Deprecated.Gets the iterator this iterator is using.- Returns:
- the iterator
-
setIterator
Deprecated.Sets the iterator for this iterator to use. If iteration has started, this effectively resets the iterator.- Parameters:
iterator- the iterator to use
-
getPredicate
Deprecated.Gets the predicate this iterator is using.- Returns:
- the predicate
-
setPredicate
Deprecated.Sets the predicate this the iterator to use.- Parameters:
predicate- the predicate to use
-