Class FilterIterator<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    java.util.Iterator<T>
    Direct Known Subclasses:
    FilterIterator

    public class FilterIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    Iterator filtering out items which do not match a given predicate.
    • Constructor Summary

      Constructors 
      Constructor Description
      FilterIterator​(java.util.Iterator<T> iterator, Predicate predicate)
      Create a new filtered iterator based on the given iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      T next()  
      void remove()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • FilterIterator

        public FilterIterator​(java.util.Iterator<T> iterator,
                              Predicate predicate)
        Create a new filtered iterator based on the given iterator.
        Parameters:
        iterator - iterator to filter
        predicate - only item matching this predicate are included
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<T>
        Throws:
        java.lang.UnsupportedOperationException - always
        See Also:
        Iterator.remove()