V - the type of elements returned by this iteratorpublic class CollectingIterator<V extends Identifiable>
extends java.lang.Object
implements java.util.Iterator<V>, java.io.Closeable
| Constructor and Description |
|---|
CollectingIterator(java.util.Iterator<V> sourceIterator,
java.util.Map<java.lang.Long,V> cache)
Creates a new CollectingIterator object with the specified iterator and caching map.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.util.Map<java.lang.Long,V> |
getCollectedValues()
Returns an unmodifiable map containing all the cached values.
|
boolean |
hasNext()
Returns true if the source iterator has more elements to fetch.
|
V |
next()
Returns the next element in the iteration and caches it in the map.
|
public CollectingIterator(java.util.Iterator<V> sourceIterator, java.util.Map<java.lang.Long,V> cache)
sourceIterator - the iterator for iterating over the elements.cache - the map to cache the already fetched elements.public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic boolean hasNext()
hasNext in interface java.util.Iterator<V extends Identifiable>public V next()
next in interface java.util.Iterator<V extends Identifiable>public java.util.Map<java.lang.Long,V> getCollectedValues()
java.lang.IllegalStateException - if not all values have been collected yetCopyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.