Class FilterListIterator<E>
java.lang.Object
org.apache.commons.collections4.iterators.FilterListIterator<E>
- 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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ListIterator
<? extends E> The iterator being usedprivate int
The index of the element that would be returned bynext()
.private E
The value of the next (matching) object, whennextObjectSet
is true.private boolean
Whether or not thenextObject
has been set (possibly tonull
).The predicate being usedprivate E
The value of the previous (matching) object, whenpreviousObjectSet
is true.private boolean
Whether or not thepreviousObject
has been set (possibly tonull
). -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newFilterListIterator
that will not function untilsetListIterator
andsetPredicate
are invoked.FilterListIterator
(ListIterator<? extends E> iterator) Constructs a newFilterListIterator
that will not function untilsetPredicate
is invoked.FilterListIterator
(ListIterator<? extends E> iterator, Predicate<? super E> predicate) Constructs a newFilterListIterator
.FilterListIterator
(Predicate<? super E> predicate) Constructs a newFilterListIterator
that will not function untilsetListIterator
is invoked. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Not supported.private void
private void
ListIterator
<? extends E> Gets the iterator this iterator is using.Gets the predicate this iterator is using.boolean
hasNext()
boolean
next()
int
previous()
int
void
remove()
Not supported.void
Not supported.void
setListIterator
(ListIterator<? extends E> iterator) Sets the iterator for this iterator to use.private boolean
void
setPredicate
(Predicate<? super E> predicate) Sets the predicate this the iterator to use.private boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
iterator
The iterator being used -
predicate
The predicate being used -
nextObject
The value of the next (matching) object, whennextObjectSet
is true. -
nextObjectSet
private boolean nextObjectSetWhether or not thenextObject
has been set (possibly tonull
). -
previousObject
The value of the previous (matching) object, whenpreviousObjectSet
is true. -
previousObjectSet
private boolean previousObjectSetWhether or not thepreviousObject
has been set (possibly tonull
). -
nextIndex
private int nextIndexThe index of the element that would be returned bynext()
.
-
-
Constructor Details
-
FilterListIterator
public FilterListIterator()Constructs a newFilterListIterator
that will not function untilsetListIterator
andsetPredicate
are invoked. -
FilterListIterator
Constructs a newFilterListIterator
that will not function untilsetPredicate
is invoked.- Parameters:
iterator
- the iterator to use
-
FilterListIterator
Constructs a newFilterListIterator
.- Parameters:
iterator
- the iterator to usepredicate
- the predicate to use
-
FilterListIterator
Constructs a newFilterListIterator
that will not function untilsetListIterator
is invoked.- Parameters:
predicate
- the predicate to use.
-
-
Method Details
-
add
Not supported.- Specified by:
add
in interfaceListIterator<E>
- Parameters:
o
- the element to insert
-
hasNext
public boolean hasNext() -
hasPrevious
public boolean hasPrevious()- Specified by:
hasPrevious
in interfaceListIterator<E>
-
next
-
nextIndex
public int nextIndex()- Specified by:
nextIndex
in interfaceListIterator<E>
-
previous
- Specified by:
previous
in interfaceListIterator<E>
-
previousIndex
public int previousIndex()- Specified by:
previousIndex
in interfaceListIterator<E>
-
remove
public void remove()Not supported. -
set
Not supported.- Specified by:
set
in interfaceListIterator<E>
- Parameters:
o
- the element with which to replace the last element returned bynext
orprevious
-
getListIterator
Gets the iterator this iterator is using.- Returns:
- the iterator.
-
setListIterator
Sets the iterator for this iterator to use. If iteration has started, this effectively resets the iterator.- Parameters:
iterator
- the iterator to use
-
getPredicate
Gets the predicate this iterator is using.- Returns:
- the predicate.
-
setPredicate
Sets the predicate this the iterator to use.- Parameters:
predicate
- the transformer to use
-
clearNextObject
private void clearNextObject() -
setNextObject
private boolean setNextObject() -
clearPreviousObject
private void clearPreviousObject() -
setPreviousObject
private boolean setPreviousObject()
-