Class ObjectIterator<E>

  • Type Parameters:
    E - The type of elements in this iterator
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Iterator<E>
    Direct Known Subclasses:
    ObjectListIterator

    public class ObjectIterator<E>
    extends java.lang.Object
    implements java.util.Iterator<E>, java.lang.Iterable<E>
    An iterable and iterator to a single object. This implementation allows null values. This implementation does not allow removal, as removing has no meaning in this context. This version releases the object when iteration has occurred (i.e. when hasNext() would return false).
    Author:
    Garret Wilson
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean hasNext
      Whether we've not retrieved the object.
      protected E object
      The single object being iterated.
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectIterator​(E object)
      Object constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      java.util.Iterator<E> iterator()
      This implementation returns this.
      E next()
      void remove()
      This implementation does not support removal.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • object

        protected E object
        The single object being iterated.
      • hasNext

        protected boolean hasNext
        Whether we've not retrieved the object.
    • Constructor Detail

      • ObjectIterator

        public ObjectIterator​(E object)
        Object constructor.
        Parameters:
        object - The single object over which iteration should occur.
    • Method Detail

      • hasNext

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

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

        public void remove()
        This implementation does not support removal.
        Specified by:
        remove in interface java.util.Iterator<E>
      • iterator

        public java.util.Iterator<E> iterator()
        This implementation returns this.
        Specified by:
        iterator in interface java.lang.Iterable<E>