Package com.day.util

Class CompoundIterator

  • All Implemented Interfaces:
    java.util.Iterator

    public class CompoundIterator
    extends java.lang.Object
    implements java.util.Iterator
    Implements the Iterator interface and combines two Iterator objects into one single Iterator.

    The constructor takes two Iterator arguments: parent and child. Calling next() on this Iterator will first try to return an element from the parent Iterator and once the parent Iterator does not have any more elements it will return elements from the child Iterator.

    Since:
    fennec Audience wad
    • Constructor Summary

      Constructors 
      Constructor Description
      CompoundIterator​(java.util.Iterator parent, java.util.Iterator child)
      Creates a CompoundIterator based on parent and child.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Returns true if either parent or child iterator has a next element; false otherwise.
      java.lang.Object next()
      Returns the next element from the parent or the child iterator object.
      void remove()
      Always throws UnsupportedOperationException
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • CompoundIterator

        public CompoundIterator​(java.util.Iterator parent,
                                java.util.Iterator child)
        Creates a CompoundIterator based on parent and child. This CompountIterator will first return elements from parent and then elements from child.
        Parameters:
        parent - the Iterator from where to return the elements first.
        child - the Iterator from where to return the elements after parent does not have elements any more.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Returns true if either parent or child iterator has a next element; false otherwise.
        Specified by:
        hasNext in interface java.util.Iterator
        Returns:
        true if either parent or child iterator has a next element; false otherwise.
      • next

        public java.lang.Object next()
        Returns the next element from the parent or the child iterator object.
        Specified by:
        next in interface java.util.Iterator
        Returns:
        the next element from the parent or the child iterator object.
      • remove

        public void remove()
                    throws java.lang.UnsupportedOperationException
        Always throws UnsupportedOperationException
        Specified by:
        remove in interface java.util.Iterator
        Throws:
        java.lang.UnsupportedOperationException - always!