Class AdapterIterator<T,​U>

  • All Implemented Interfaces:
    java.util.Iterator<T>

    public abstract class AdapterIterator<T,​U>
    extends java.lang.Object
    implements java.util.Iterator<T>
    Iterator implementation that works as a filter to another iterator.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Iterator<? extends U> core  
      private T next  
    • Constructor Summary

      Constructors 
      Constructor Description
      AdapterIterator​(java.util.Iterator<? extends U> core)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract T adapt​(U u)  
      private void fetch()  
      boolean hasNext()  
      T next()  
      void remove()  
      • 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

      • core

        private final java.util.Iterator<? extends U> core
      • next

        private T next
    • Constructor Detail

      • AdapterIterator

        public AdapterIterator​(java.util.Iterator<? extends U> core)
    • Method Detail

      • next

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

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

        private void fetch()
      • remove

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

        protected abstract T adapt​(U u)
        Returns:
        null to filter out this object. Non-null object will be returned from the iterator to the caller.