- Type Parameters:
T
- the contained element type
public class SingleContainer<T>
extends java.lang.Object
Helper class that stores a single element.
The caller may add a new element only when the container is empty and
the caller may take the contained element if there is one.
Use the isEmpty()
to check for the status
The add and take methods might throw IllegalStateException
,
which should indicate a library bug.
Typically used by the Interactive methods to help them conform with the Iterable contract,
e.g., hasNext()
is idempotent, but next()
might
be called without hasNext()
to be called at all.
The container is not thread-safe.