Class FilterIterator
- java.lang.Object
-
- org.apache.commons.collections.iterators.FilterIterator
-
- All Implemented Interfaces:
java.util.Iterator
- Direct Known Subclasses:
UniqueFilterIterator
@Deprecated(since="2021-04-30") public class FilterIterator extends java.lang.Object implements java.util.Iterator
Deprecated.Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.Decorates anotherIterator
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
Constructors Constructor Description FilterIterator()
Deprecated.Constructs a newFilterIterator
that will not function untilsetIterator
is invoked.FilterIterator(java.util.Iterator iterator)
Deprecated.Constructs a newFilterIterator
that will not function untilsetPredicate
is invoked.FilterIterator(java.util.Iterator iterator, Predicate predicate)
Deprecated.Constructs a newFilterIterator
that will use the given iterator and predicate.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Iterator
getIterator()
Deprecated.Gets the iterator this iterator is using.Predicate
getPredicate()
Deprecated.Gets the predicate this iterator is using.boolean
hasNext()
Deprecated.Returns true if the underlying iterator contains an object that matches the predicate.java.lang.Object
next()
Deprecated.Returns the next object that matches the predicate.void
remove()
Deprecated.Removes from the underlying collection of the base iterator the last element returned by this iterator.void
setIterator(java.util.Iterator iterator)
Deprecated.Sets the iterator for this iterator to use.void
setPredicate(Predicate predicate)
Deprecated.Sets the predicate this the iterator to use.
-
-
-
Constructor Detail
-
FilterIterator
public FilterIterator()
Deprecated.Constructs a newFilterIterator
that will not function untilsetIterator
is invoked.
-
FilterIterator
public FilterIterator(java.util.Iterator iterator)
Deprecated.Constructs a newFilterIterator
that will not function untilsetPredicate
is invoked.- Parameters:
iterator
- the iterator to use
-
FilterIterator
public FilterIterator(java.util.Iterator iterator, Predicate predicate)
Deprecated.Constructs a newFilterIterator
that will use the given iterator and predicate.- Parameters:
iterator
- the iterator to usepredicate
- the predicate to use
-
-
Method Detail
-
hasNext
public boolean hasNext()
Deprecated.Returns true if the underlying iterator contains an object that matches the predicate.- Specified by:
hasNext
in interfacejava.util.Iterator
- Returns:
- true if there is another object that matches the predicate
- Throws:
java.lang.NullPointerException
- if either the iterator or predicate are null
-
next
public java.lang.Object next()
Deprecated.Returns the next object that matches the predicate.- Specified by:
next
in interfacejava.util.Iterator
- Returns:
- the next object which matches the given predicate
- Throws:
java.lang.NullPointerException
- if either the iterator or predicate are nulljava.util.NoSuchElementException
- 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:
remove
in interfacejava.util.Iterator
- Throws:
java.lang.IllegalStateException
- ifhasNext()
has already been called.
-
getIterator
public java.util.Iterator getIterator()
Deprecated.Gets the iterator this iterator is using.- Returns:
- the iterator
-
setIterator
public void setIterator(java.util.Iterator iterator)
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
public Predicate getPredicate()
Deprecated.Gets the predicate this iterator is using.- Returns:
- the predicate
-
setPredicate
public void setPredicate(Predicate predicate)
Deprecated.Sets the predicate this the iterator to use.- Parameters:
predicate
- the predicate to use
-
-