Class DefaultCloseableIterator<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    Closeable, AutoCloseable, Iterator<T>, CloseableIterator<T>

    public class DefaultCloseableIterator<T>
    extends Object
    implements CloseableIterator<T>
    Default implementation of CloseableIterator
    • Field Summary

      Modifier and Type Field Description
      protected Closeable closeableItem  
      protected Iterator<T> wrapped  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the underlying iterator in case it implements CloseableIterator.
      protected void finalize()  
      boolean hasNext()  
      T next()  
      void remove()  
      • Methods inherited from class Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface Iterator

    • Field Detail

      • wrapped

        protected final Iterator<T> wrapped
      • closeableItem

        protected Closeable closeableItem
    • Constructor Detail

      • DefaultCloseableIterator

        public DefaultCloseableIterator​(Iterator<T> wrapped)
      • DefaultCloseableIterator

        public DefaultCloseableIterator​(Iterator<T> wrapped,
                                        Closeable closeable)
    • Method Detail

      • hasNext

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

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

        public void remove()
        Specified by:
        remove in interface Iterator<T>
      • close

        public void close()
        Closes the underlying iterator in case it implements CloseableIterator.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface CloseableIterator<T>
      • finalize

        protected void finalize()
        finalize in class Object