|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jut.lang.AbstractOneTimeIterable<T>
public abstract class AbstractOneTimeIterable<T>
template implementation of OneTimeIterable
. the iterator of this template does not
support the Iterator.remove()
method. as convenience, a user method can be called before
handing over the result of Iterator.next()
, see onNext(jut.lang.ParamRunnable)
.
the "one Iterator
only" check is thread safe.
this template class is part of the problem solution that in the standard JDK, Iterable
s
are supposed to produce any number of Iterator
s. see also OneTimeIterable
and
OneTimeIterableWrapper
.
Constructor Summary | |
---|---|
AbstractOneTimeIterable()
|
Method Summary | |
---|---|
Iterator<T> |
iterator()
the first time called, returns an iterator over a set of elements of type T. subsequent calls should result in an IllegalStateException . |
protected abstract boolean |
iteratorHasNext()
returns true if the iterator has more elements. |
protected abstract T |
iteratorNext()
returns the next element in the iterator. |
void |
onNext(ParamRunnable<T> onNextObject)
set the convenience user object to call before handing over the result of Iterator.next() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractOneTimeIterable()
Method Detail |
---|
public final void onNext(ParamRunnable<T> onNextObject)
Iterator.next()
.
onNextObject
- - the convenience user object to call before handing over the result of
Iterator.next()
.public final Iterator<T> iterator()
IllegalStateException
. the iterator does not support the Iterator.remove()
method. the
"one Iterator
only" check is thread safe.
iterator
in interface Iterable<T>
iterator
in interface OneTimeIterable<T>
protected abstract T iteratorNext() throws Exception
Exception
- to indicate something went wrong. the exception is re-thrown, either directly
(for RuntimeException
s, or as NestedException
.protected abstract boolean iteratorHasNext() throws Exception
iteratorNext()
would return an element rather than throwing an exception.)
true
if the iterator has more elements, false
if not.
Exception
- to indicate something went wrong. the exception is re-thrown, either directly
(for RuntimeException
s, or as NestedException
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |