public class
CloseableIterableOnce
extends Object
implements CloseableIterable<T>
implements CloseableIterable<T>
A CloseableIterable
that can be iterated over at most once. Additional calls to
iterator()
will throw an IllegalStateException
.
This class does not override Object.equals
.
Public Constructor Summary
CloseableIterableOnce(Iterator<T> iterator)
Constructs an instance wrapping the given iterator.
|
Public Method Summary
void |
close()
Closes any resources associated with this iterator.
|
Iterator<T> |
iterator()
Gets the wrapped iterator on the first call, and throws an exception on all subsequent calls.
|
Inherited Method Summary
Public Constructors
public CloseableIterableOnce (Iterator<T> iterator)
Constructs an instance wrapping the given iterator.
Parameters
iterator | the iterator to wrap |
---|
Throws
NullPointerException | if iterator is null
|
---|
Public Methods
public void close ()
Closes any resources associated with this iterator. This implementation invalidates the iterator.
public Iterator<T> iterator ()
Gets the wrapped iterator on the first call, and throws an exception on all subsequent calls.
Returns
- the wrapped iterator on the first call
Throws
IllegalStateException | if this method has been called on this instance before |
---|