Class FilterListIterator<E>
- java.lang.Object
-
- org.apache.commons.collections4.iterators.FilterListIterator<E>
-
- All Implemented Interfaces:
java.util.Iterator<E>,java.util.ListIterator<E>
public class FilterListIterator<E> extends java.lang.Object implements java.util.ListIterator<E>Decorates anotherListIteratorusing a predicate to filter elements.This iterator decorates the underlying iterator, only allowing through those elements that match the specified
Predicate.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description FilterListIterator()Constructs a newFilterListIteratorthat will not function untilsetListIteratorandsetPredicateare invoked.FilterListIterator(java.util.ListIterator<? extends E> iterator)Constructs a newFilterListIteratorthat will not function untilsetPredicateis invoked.FilterListIterator(java.util.ListIterator<? extends E> iterator, Predicate<? super E> predicate)Constructs a newFilterListIterator.FilterListIterator(Predicate<? super E> predicate)Constructs a newFilterListIteratorthat will not function untilsetListIteratoris invoked.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(E o)Not supported.java.util.ListIterator<? extends E>getListIterator()Gets the iterator this iterator is using.Predicate<? super E>getPredicate()Gets the predicate this iterator is using.booleanhasNext()booleanhasPrevious()Enext()intnextIndex()Eprevious()intpreviousIndex()voidremove()Not supported.voidset(E o)Not supported.voidsetListIterator(java.util.ListIterator<? extends E> iterator)Sets the iterator for this iterator to use.voidsetPredicate(Predicate<? super E> predicate)Sets the predicate this the iterator to use.
-
-
-
Constructor Detail
-
FilterListIterator
public FilterListIterator()
Constructs a newFilterListIteratorthat will not function untilsetListIteratorandsetPredicateare invoked.
-
FilterListIterator
public FilterListIterator(java.util.ListIterator<? extends E> iterator)
Constructs a newFilterListIteratorthat will not function untilsetPredicateis invoked.- Parameters:
iterator- the iterator to use
-
FilterListIterator
public FilterListIterator(java.util.ListIterator<? extends E> iterator, Predicate<? super E> predicate)
Constructs a newFilterListIterator.- Parameters:
iterator- the iterator to usepredicate- the predicate to use
-
FilterListIterator
public FilterListIterator(Predicate<? super E> predicate)
Constructs a newFilterListIteratorthat will not function untilsetListIteratoris invoked.- Parameters:
predicate- the predicate to use.
-
-
Method Detail
-
add
public void add(E o)
Not supported.- Specified by:
addin interfacejava.util.ListIterator<E>- Parameters:
o- the element to insert
-
hasNext
public boolean hasNext()
-
hasPrevious
public boolean hasPrevious()
- Specified by:
hasPreviousin interfacejava.util.ListIterator<E>
-
next
public E next()
-
nextIndex
public int nextIndex()
- Specified by:
nextIndexin interfacejava.util.ListIterator<E>
-
previousIndex
public int previousIndex()
- Specified by:
previousIndexin interfacejava.util.ListIterator<E>
-
remove
public void remove()
Not supported.
-
set
public void set(E o)
Not supported.- Specified by:
setin interfacejava.util.ListIterator<E>- Parameters:
o- the element with which to replace the last element returned bynextorprevious
-
getListIterator
public java.util.ListIterator<? extends E> getListIterator()
Gets the iterator this iterator is using.- Returns:
- the iterator.
-
setListIterator
public void setListIterator(java.util.ListIterator<? extends E> iterator)
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<? super E> getPredicate()
Gets the predicate this iterator is using.- Returns:
- the predicate.
-
-