Class EmptyIterator<T>

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

    public final class EmptyIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    Simple implementation of "null iterator", iterator that has nothing to iterate over.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static EmptyIterator<java.lang.Object> sInstance  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private EmptyIterator()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> EmptyIterator<T> getInstance()
      Since the actual type has no effect (as this iterator never returns any value objects), we can just cast away here: bit unclean, but safe.
      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

      • sInstance

        static final EmptyIterator<java.lang.Object> sInstance
    • Constructor Detail

      • EmptyIterator

        private EmptyIterator()
    • Method Detail

      • getInstance

        public static <T> EmptyIterator<T> getInstance()
        Since the actual type has no effect (as this iterator never returns any value objects), we can just cast away here: bit unclean, but safe.
      • 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>