Package com.day.util
Class CompoundIterator
- java.lang.Object
-
- com.day.util.CompoundIterator
-
- All Implemented Interfaces:
java.util.Iterator
public class CompoundIterator extends java.lang.Object implements java.util.Iterator
Implements theIterator
interface and combines twoIterator
objects into one singleIterator
.The constructor takes two
Iterator
arguments:parent
andchild
. Callingnext()
on thisIterator
will first try to return an element from the parentIterator
and once the parentIterator
does not have any more elements it will return elements from the childIterator
.- Since:
- fennec Audience wad
-
-
Constructor Summary
Constructors Constructor Description CompoundIterator(java.util.Iterator parent, java.util.Iterator child)
Creates aCompoundIterator
based onparent
andchild
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
Returnstrue
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 throwsUnsupportedOperationException
-
-
-
Constructor Detail
-
CompoundIterator
public CompoundIterator(java.util.Iterator parent, java.util.Iterator child)
Creates aCompoundIterator
based onparent
andchild
. ThisCompountIterator
will first return elements fromparent
and then elements fromchild
.- Parameters:
parent
- theIterator
from where to return the elements first.child
- theIterator
from where to return the elements afterparent
does not have elements any more.
-
-
Method Detail
-
hasNext
public boolean hasNext()
Returnstrue
if either parent or child iterator has a next element;false
otherwise.- Specified by:
hasNext
in interfacejava.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 interfacejava.util.Iterator
- Returns:
- the next element from the parent or the child iterator object.
-
remove
public void remove() throws java.lang.UnsupportedOperationException
Always throwsUnsupportedOperationException
- Specified by:
remove
in interfacejava.util.Iterator
- Throws:
java.lang.UnsupportedOperationException
- always!
-
-