java.lang.Object
org.bzdev.util.EncapsulatingIterator<E,T>
- Type Parameters:
T
- the type of the values produced by an existing iteratorE
- the type of the values produced by this iterator
- All Implemented Interfaces:
Iterator<E>
- Direct Known Subclasses:
NamedObjectFactory.ParmNameIterator
Encapsulating iterator class.
An encapsulating iterator uses an iterator passed to its
constructor to generate a sequence of objects of type T.
Instead of returning an object of type T when next() is called, an object
of a different type E is returned.
The method next() is responsible for constructing an object of type E
from the corresponding object of type T.
One use is in conjunction with a template processor, where objects of type Iterator<TemplateProcessor.KeyMap> can be used for iteration.
-
Constructor Details
-
EncapsulatingIterator
Constructor.- Parameters:
it
- the iterator to encapsulate
-
-
Method Details
-
hasNext
public boolean hasNext() -
encapsulatedNext
Get the next element using the iterator passed to the constructor. This method must be called once and only once bynext()
for each call tonext()
.- Returns:
- the next element from the encapsulated iterator.
-
next
Return the next element in the iteration. Typically, this method will create a new element of type E and then configure it based on the value returned by a single call to encapsulatedNext(). -
remove
public void remove()
-