T
- the type of elementpublic interface Handler<T>
Implementations of this interface are accepted by methods that performs an internal, push-style
iteration by forwarding a sequence of elements, one at a time, to a supplied Handler; to this
respect, this interface complements the Iterator
which supports an external, pull-style
iteration.
A Handler implements a single method handle(Object)
that is called for each object of
the sequence, which MUST not be null; at the end of the sequence, the method is called a last
time passing null as sentinel value. This interface does not specify how to interrupt the
iteration and how to deal with exceptions, which depend on (and are documented as part of) the
specific method accepting a Handler. In particular:
Thread.interrupt()
), which may be triggered inside the
handle()
method and will cause, eventually, the end of the iteration;
Implementations of this interface are not expected to be thread safe. It is a responsibility of
the caller of handle(Object)
to never invoke this method multiple times concurrently.
Modifier and Type | Method and Description |
---|---|
void |
handle(T element)
Callback method called for each non-null element of the sequence, and with a null value at
the end of the sequence.
|
Copyright © 2015–2016 FBK-irst. All rights reserved.