Class FilterListIterator<E>
java.lang.Object
org.apache.commons.collections4.iterators.FilterListIterator<E>
- Type Parameters:
E- The type of elements returned by this iterator.
- All Implemented Interfaces:
Iterator<E>,ListIterator<E>
Decorates another
ListIterator using 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
ConstructorsConstructorDescriptionConstructs a newFilterListIteratorthat will not function untilsetListIteratorandsetPredicateare invoked.FilterListIterator(ListIterator<? extends E> iterator) Constructs a newFilterListIteratorthat will not function untilsetPredicateis invoked.FilterListIterator(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
Modifier and TypeMethodDescriptionvoidAlways throwsUnsupportedOperationException.ListIterator<? extends E> Gets the iterator this iterator is using.Gets the predicate this iterator is using.booleanhasNext()booleannext()intprevious()intvoidremove()Always throwsUnsupportedOperationException.voidAlways throwsUnsupportedOperationException.voidsetListIterator(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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
FilterListIterator
public FilterListIterator()Constructs a newFilterListIteratorthat will not function untilsetListIteratorandsetPredicateare invoked. -
FilterListIterator
Constructs a newFilterListIteratorthat will not function untilsetPredicateis invoked.- Parameters:
iterator- The iterator to use
-
FilterListIterator
Constructs a newFilterListIterator.- Parameters:
iterator- The iterator to usepredicate- The predicate to use
-
FilterListIterator
Constructs a newFilterListIteratorthat will not function untilsetListIteratoris invoked.- Parameters:
predicate- The predicate to use.
-
-
Method Details
-
add
Always throwsUnsupportedOperationException.- Specified by:
addin interfaceListIterator<E>- Parameters:
o- ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
getListIterator
Gets the iterator this iterator is using.- Returns:
- The iterator.
-
getPredicate
Gets the predicate this iterator is using.- Returns:
- The predicate.
-
hasNext
-
hasPrevious
- Specified by:
hasPreviousin interfaceListIterator<E>
-
next
-
nextIndex
- Specified by:
nextIndexin interfaceListIterator<E>
-
previous
- Specified by:
previousin interfaceListIterator<E>
-
previousIndex
- Specified by:
previousIndexin interfaceListIterator<E>
-
remove
Always throwsUnsupportedOperationException.- Specified by:
removein interfaceIterator<E>- Specified by:
removein interfaceListIterator<E>- Throws:
UnsupportedOperationException- Always thrown.
-
set
Always throwsUnsupportedOperationException.- Specified by:
setin interfaceListIterator<E>- Parameters:
e- ignored.- Throws:
UnsupportedOperationException- Always thrown.
-
setListIterator
Sets the iterator for this iterator to use. If iteration has started, this effectively resets the iterator.- Parameters:
iterator- The iterator to use
-
setPredicate
Sets the predicate this the iterator to use.- Parameters:
predicate- The transformer to use
-