Class ExpandingLeafIterator<T>
- java.lang.Object
-
- com.saperion.common.lang.iterator.ExpandingLeafIterator<T>
-
- Type Parameters:
T
- type of objects to iterate
- All Implemented Interfaces:
java.util.Iterator<T>
public final class ExpandingLeafIterator<T> extends java.lang.Object implements java.util.Iterator<T>
An
ExpandingLeafIterator
iterates through the leaf nodes of a virtual two level data structure.It iterates through the objects of the specified main iterator. For each such main level object a call to the specified
IteratorResolver
is executed to get an iterator for the optional virtual sub elements. If such an iterator is found, all the sub elements will be iterated through. Only if no such iterator is found the object of the main level will be returned.ATTENTION: If a sub-level iterator is found but is empty, no elements will be iterated through and the main level object is NOT returned, because there was a valid (but empty) sub level. The main level object is only returned if the
IteratorResolver
returnsnull
, indicating that there is no sub level for this main object.Then, the main iterator will step to the next main object and its sub elements and so on.
Iterator.remove()
is not supported.- Author:
- agz
- See Also:
ExpandingNodeIterator
,ExpandingSubLevelIterator
-
-
Constructor Summary
Constructors Constructor Description ExpandingLeafIterator(java.util.Iterator<? extends T> iterator, IteratorResolver<T,T> iteratorResolver)
Creates a newExpandingLeafIterator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
T
next()
void
remove()
java.lang.String
toString()
-
-
-
Constructor Detail
-
ExpandingLeafIterator
public ExpandingLeafIterator(java.util.Iterator<? extends T> iterator, IteratorResolver<T,T> iteratorResolver)
Creates a newExpandingLeafIterator
. The specified iterator and the specified iterator resolver must not benull
.- Parameters:
iterator
- main level iteratoriteratorResolver
-IteratorResolver
- See Also:
class documentation for details
-
-