Package org.apache.commons.collections4.iterators

# 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>`

public class FilterListIterator<E> extends Object implements 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

  Constructors
  Constructor
  Description
  `FilterListIterator()`
  Constructs a new `FilterListIterator` that will not function until `setListIterator` and `setPredicate` are invoked.
  `FilterListIterator(ListIterator<? extends E> iterator)`
  Constructs a new `FilterListIterator` that will not function until `setPredicate` is invoked.
  `FilterListIterator(ListIterator<? extends E> iterator, Predicate<? super E> predicate)`
  Constructs a new `FilterListIterator`.
  `FilterListIterator(Predicate<? super E> predicate)`
  Constructs a new `FilterListIterator` that will not function until `setListIterator` is invoked.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(E o)`
  Always throws `UnsupportedOperationException`.
  `ListIterator<? extends E>`
  `getListIterator()`
  Gets the iterator this iterator is using.
  `Predicate<? super E>`
  `getPredicate()`
  Gets the predicate this iterator is using.
  `boolean`
  `hasNext()`
  `boolean`
  `hasPrevious()`
  `E`
  `next()`
  `int`
  `nextIndex()`
  `E`
  `previous()`
  `int`
  `previousIndex()`
  `void`
  `remove()`
  Always throws `UnsupportedOperationException`.
  `void`
  `set(E e)`
  Always throws `UnsupportedOperationException`.
  `void`
  `setListIterator(ListIterator<? extends E> iterator)`
  Sets the iterator for this iterator to use.
  `void`
  `setPredicate(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, wait`

  ### Methods inherited from interface java.util.Iterator

  `forEachRemaining`

- ## Constructor Details

  - ### FilterListIterator

    public FilterListIterator()
    Constructs a new `FilterListIterator` that will not function until `setListIterator` and `setPredicate` are invoked.

  - ### FilterListIterator

    public FilterListIterator(ListIterator<? extends E> iterator)
    Constructs a new `FilterListIterator` that will not function until `setPredicate` is invoked.
    Parameters:
      `iterator` - The iterator to use

  - ### FilterListIterator

    public FilterListIterator(ListIterator<? extends E> iterator, Predicate<? super E> predicate)
    Constructs a new `FilterListIterator`.
    Parameters:
      `iterator` - The iterator to use
      `predicate` - The predicate to use

  - ### FilterListIterator

    public FilterListIterator(Predicate<? super E> predicate)
    Constructs a new `FilterListIterator` that will not function until `setListIterator` is invoked.
    Parameters:
      `predicate` - The predicate to use.

- ## Method Details

  - ### add

    public void add(E o)
    Always throws `UnsupportedOperationException`.
    Specified by:
      `add` in interface `ListIterator<E>`
    Parameters:
      `o` - ignored.
    Throws:
      `UnsupportedOperationException` - Always thrown.

  - ### getListIterator

    public ListIterator<? extends E> getListIterator()
    Gets the iterator this iterator is using.
    Returns:
      The iterator.

  - ### getPredicate

    public Predicate<? super E> getPredicate()
    Gets the predicate this iterator is using.
    Returns:
      The predicate.

  - ### hasNext

    public boolean hasNext()
    Specified by:
      `hasNext` in interface `Iterator<E>`
    Specified by:
      `hasNext` in interface `ListIterator<E>`

  - ### hasPrevious

    public boolean hasPrevious()
    Specified by:
      `hasPrevious` in interface `ListIterator<E>`

  - ### next

    public E next()
    Specified by:
      `next` in interface `Iterator<E>`
    Specified by:
      `next` in interface `ListIterator<E>`

  - ### nextIndex

    public int nextIndex()
    Specified by:
      `nextIndex` in interface `ListIterator<E>`

  - ### previous

    public E previous()
    Specified by:
      `previous` in interface `ListIterator<E>`

  - ### previousIndex

    public int previousIndex()
    Specified by:
      `previousIndex` in interface `ListIterator<E>`

  - ### remove

    public void remove()
    Always throws `UnsupportedOperationException`.
    Specified by:
      `remove` in interface `Iterator<E>`
    Specified by:
      `remove` in interface `ListIterator<E>`
    Throws:
      `UnsupportedOperationException` - Always thrown.

  - ### set

    public void set(E e)
    Always throws `UnsupportedOperationException`.
    Specified by:
      `set` in interface `ListIterator<E>`
    Parameters:
      `e` - ignored.
    Throws:
      `UnsupportedOperationException` - Always thrown.

  - ### setListIterator

    public void setListIterator(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

  - ### setPredicate

    public void setPredicate(Predicate<? super E> predicate)
    Sets the predicate this the iterator to use.
    Parameters:
      `predicate` - The transformer to use