Class IteratorAdapter<T>

  • All Implemented Interfaces:
    CloseableIterator<T>, java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator<T>

    public class IteratorAdapter<T>
    extends java.lang.Object
    implements CloseableIterator<T>
    Adapter implementation for Iterator and CloseableIterator instances
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.Closeable closeable  
      private java.util.Iterator<T> iter  
    • Constructor Summary

      Constructors 
      Constructor Description
      IteratorAdapter​(java.util.Iterator<T> iter)  
      IteratorAdapter​(java.util.Iterator<T> iter, java.io.Closeable closeable)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<T> asList()  
      static <T> java.util.List<T> asList​(java.util.Iterator<T> iter)  
      void close()
      Closes this iterator and releases any system resources associated with it.
      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

      • iter

        private final java.util.Iterator<T> iter
      • closeable

        private final java.io.Closeable closeable
    • Constructor Detail

      • IteratorAdapter

        public IteratorAdapter​(java.util.Iterator<T> iter)
      • IteratorAdapter

        public IteratorAdapter​(java.util.Iterator<T> iter,
                               java.io.Closeable closeable)
    • Method Detail

      • asList

        public static <T> java.util.List<T> asList​(java.util.Iterator<T> iter)
      • asList

        public java.util.List<T> asList()
      • close

        public void close()
        Description copied from interface: CloseableIterator
        Closes this iterator and releases any system resources associated with it. If the iterator is already closed then invoking this method has no effect.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface CloseableIterator<T>
      • 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>