T
- the type of elements returned by this iteratorpublic interface CloseableIterable<T>
extends Iterable<T>, java.io.Closeable
Iterable
interface to provide a way to close the iterator.Modifier and Type | Method and Description |
---|---|
static <T> CloseableIterable<T> |
emptyIterable()
Return an
CloseableIterable object for an empty collection. |
default void |
forEach(java.util.function.Consumer<? super T> action) |
static <T> CloseableIterable<T> |
inMemoryIterable(CloseableIterator<T> iterator)
Return an
CloseableIterable object that is backed by an in-memory collection of given
CloseableIterator . |
CloseableIterator<T> |
iterator()
Overrides the default iterator method to return a
CloseableIterator . |
default java.util.Spliterator<T> |
spliterator() |
CloseableIterator<T> iterator()
CloseableIterator
.iterator
in interface Iterable<T>
CloseableIterator
instance.default void forEach(java.util.function.Consumer<? super T> action)
forEach
in interface Iterable<T>
default java.util.Spliterator<T> spliterator()
spliterator
in interface Iterable<T>
static <T> CloseableIterable<T> inMemoryIterable(CloseableIterator<T> iterator)
CloseableIterable
object that is backed by an in-memory collection of given
CloseableIterator
. Users should aware that the returned CloseableIterable
will
hold the data in memory.T
- the type of elements returned by the iteratoriterator
- the iterator to be converted to a CloseableIterable
. It will be closed
by this callee.CloseableIterable
instance.static <T> CloseableIterable<T> emptyIterable()
CloseableIterable
object for an empty collection.T
- the type of elements returned by the iteratorCloseableIterable
instance.