public class FilterListIterator
extends java.lang.Object
implements java.util.ListIterator
ListIterator using a predicate to filter elements.
This iterator decorates the underlying iterator, only allowing through
those elements that match the specified Predicate.
| Modifier and Type | Field and Description |
|---|---|
private java.util.ListIterator |
iterator
The iterator being used
|
private int |
nextIndex
The index of the element that would be returned by
next(). |
private java.lang.Object |
nextObject
The value of the next (matching) object, when
nextObjectSet is true. |
private boolean |
nextObjectSet
Whether or not the
nextObject has been set
(possibly to null). |
private Predicate |
predicate
The predicate being used
|
private java.lang.Object |
previousObject
The value of the previous (matching) object, when
previousObjectSet is true. |
private boolean |
previousObjectSet
Whether or not the
previousObject has been set
(possibly to null). |
| Constructor and Description |
|---|
FilterListIterator()
Constructs a new
FilterListIterator that will not function
until setListIterator
and setPredicate are invoked. |
FilterListIterator(java.util.ListIterator iterator)
Constructs a new
FilterListIterator that will not
function until setPredicate is invoked. |
FilterListIterator(java.util.ListIterator iterator,
Predicate predicate)
Constructs a new
FilterListIterator. |
FilterListIterator(Predicate predicate)
Constructs a new
FilterListIterator that will not function
until setListIterator is invoked. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.Object o)
Not supported.
|
private void |
clearNextObject() |
private void |
clearPreviousObject() |
java.util.ListIterator |
getListIterator()
Gets the iterator this iterator is using.
|
Predicate |
getPredicate()
Gets the predicate this iterator is using.
|
boolean |
hasNext() |
boolean |
hasPrevious() |
java.lang.Object |
next() |
int |
nextIndex() |
java.lang.Object |
previous() |
int |
previousIndex() |
void |
remove()
Not supported.
|
void |
set(java.lang.Object o)
Not supported.
|
void |
setListIterator(java.util.ListIterator iterator)
Sets the iterator for this iterator to use.
|
private boolean |
setNextObject() |
void |
setPredicate(Predicate predicate)
Sets the predicate this the iterator to use.
|
private boolean |
setPreviousObject() |
private java.util.ListIterator iterator
private Predicate predicate
private java.lang.Object nextObject
nextObjectSet is true.private boolean nextObjectSet
nextObject has been set
(possibly to null).private java.lang.Object previousObject
previousObjectSet is true.private boolean previousObjectSet
previousObject has been set
(possibly to null).private int nextIndex
next().public FilterListIterator()
FilterListIterator that will not function
until setListIterator
and setPredicate are invoked.public FilterListIterator(java.util.ListIterator iterator)
FilterListIterator that will not
function until setPredicate is invoked.iterator - the iterator to usepublic FilterListIterator(java.util.ListIterator iterator,
Predicate predicate)
FilterListIterator.iterator - the iterator to usepredicate - the predicate to usepublic FilterListIterator(Predicate predicate)
FilterListIterator that will not function
until setListIterator is invoked.predicate - the predicate to use.public void add(java.lang.Object o)
add in interface java.util.ListIteratorpublic boolean hasNext()
hasNext in interface java.util.IteratorhasNext in interface java.util.ListIteratorpublic boolean hasPrevious()
hasPrevious in interface java.util.ListIteratorpublic java.lang.Object next()
next in interface java.util.Iteratornext in interface java.util.ListIteratorpublic int nextIndex()
nextIndex in interface java.util.ListIteratorpublic java.lang.Object previous()
previous in interface java.util.ListIteratorpublic int previousIndex()
previousIndex in interface java.util.ListIteratorpublic void remove()
remove in interface java.util.Iteratorremove in interface java.util.ListIteratorpublic void set(java.lang.Object o)
set in interface java.util.ListIteratorpublic java.util.ListIterator getListIterator()
public void setListIterator(java.util.ListIterator iterator)
iterator - the iterator to usepublic Predicate getPredicate()
public void setPredicate(Predicate predicate)
predicate - the transformer to useprivate void clearNextObject()
private boolean setNextObject()
private void clearPreviousObject()
private boolean setPreviousObject()