- All Superinterfaces:
- AutoCloseable, Closeable
- All Known Implementing Classes:
- ExecuteWhenDoneYielder
public interface Yielder<T>
extends Closeable
A Yielder is an object that tries to act like the yield() command/continuations in other languages. It's not
necessarily good at this job, but it works. I think.
Essentially, you can think of a Yielder as a linked list of items where the Yielder gives you access to the current
head via get() and it will give you another Yielder representing the next item in the chain via next(). When using
a yielder object, a call to yield() on the yielding accumulator will result in a new Yielder being returned whose
get() method will return the return value of the accumulator from the call that called yield().
When a call to next() exhausts the underlying data stream without having a yield() call, various implementations
of Sequences and Yielders assume that they will receive a Yielder where isDone() is true and get() will return the
accumulated value up until that point.
Once next is called, there is no guarantee and no requirement that references to old Yielder objects will continue
to obey the contract.
Yielders are Closeable and *must* be closed in order to prevent resource leaks. Once close() is called, the behavior
of the whole chain of Yielders is undefined.