Class FilterListIterator

  • All Implemented Interfaces:
    Iterator, ListIterator

    public class FilterListIterator
    extends Object
    implements ListIterator
    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:
    Commons Collections 2.0
    Version:
    $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
    Author:
    Rodney Waldhoff
    • Constructor Detail

      • FilterListIterator

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

        public FilterListIterator​(ListIterator iterator)
        Constructs a new FilterListIterator that will not function until setPredicate is invoked.
        Parameters:
        iterator - the iterator to use
      • FilterListIterator

        public FilterListIterator​(ListIterator iterator,
                                  Predicate predicate)
        Constructs a new FilterListIterator.
        Parameters:
        iterator - the iterator to use
        predicate - the predicate to use
      • FilterListIterator

        public FilterListIterator​(Predicate predicate)
        Constructs a new FilterListIterator that will not function until setListIterator is invoked.
        Parameters:
        predicate - the predicate to use.
    • Method Detail

      • getListIterator

        public ListIterator getListIterator()
        Gets the iterator this iterator is using.
        Returns:
        the iterator.
      • setListIterator

        public void setListIterator​(ListIterator 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 getPredicate()
        Gets the predicate this iterator is using.
        Returns:
        the predicate.
      • setPredicate

        public void setPredicate​(Predicate predicate)
        Sets the predicate this the iterator to use.
        Parameters:
        predicate - the transformer to use