T - public interface CloseableIterator<T> extends Iterator<T>, Closeable
CloseableIterator serves as a bridging data structure for the underlying data store specific results that
can be wrapped in a Java 8 java.util.stream.Stream. This allows implementations to clean up any
resources they need to keep open to iterate over elements.| Modifier and Type | Method and Description |
|---|---|
void |
close() |
default Spliterator<T> |
spliterator()
Create a
Spliterator over the elements provided by this Iterator. |
default Stream<T> |
stream()
Return a sequential
Stream with this Iterator as its source. |
forEachRemaining, hasNext, next, removevoid close()
close in interface AutoCloseableclose in interface Closeabledefault Spliterator<T> spliterator()
Spliterator over the elements provided by this Iterator. Implementations should document
characteristic values reported by the spliterator. Such characteristic values are not required to be reported if
the spliterator reports Spliterator.SIZED and this collection contains no elements.
The default implementation should be overridden by subclasses that can return a more efficient spliterator. To
preserve expected laziness behavior for the stream() method, spliterators should either have the
characteristic of IMMUTABLE or CONCURRENT, or be late-binding.
The default implementation does not report a size.
Spliterator over the elements in this Iterator.default Stream<T> stream()
Stream with this Iterator as its source. The resulting stream calls
close() when closed. The resulting Stream must be closed after use, it can
be declared as a resource in a try-with-resources statement.
This method should be overridden when the spliterator() method cannot return a spliterator that is
IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.)
Stream over the elements in this Iterator.Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.