Class FilterIterator<T,​InnerT extends T>

  • Type Parameters:
    T - generic parameter for this iterator instance: this iterator implements Iterator<T>
    InnerT - generic parameter of the wrapped iterator, must be T or extend T
    All Implemented Interfaces:
    java.util.Iterator<T>

    public abstract class FilterIterator<T,​InnerT extends T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    An Iterator implementation that filters elements with a boolean predicate.
    See Also:
    predicateFunction(InnerT)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Iterator<InnerT> iterator  
      private T next  
      private boolean nextIsSet  
    • Constructor Summary

      Constructors 
      Constructor Description
      FilterIterator​(java.util.Iterator<InnerT> baseIterator)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      T next()  
      protected abstract boolean predicateFunction​(InnerT object)
      returns true, if this element should be returned by next().
      void remove()  
      private boolean setNext()  
      • 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 Detail

      • iterator

        private final java.util.Iterator<InnerT extends T> iterator
      • next

        private T next
      • nextIsSet

        private boolean nextIsSet
    • Constructor Detail

      • FilterIterator

        public FilterIterator​(java.util.Iterator<InnerT> baseIterator)
    • Method Detail

      • predicateFunction

        protected abstract boolean predicateFunction​(InnerT object)
        returns true, if this element should be returned by next().
      • hasNext

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

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

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

        private boolean setNext()