T
- the type of iterated elements.@Public public interface CloseableIterator<T> extends Iterator<T>, AutoCloseable
Iterator
that is also AutoCloseable
. A typical
use-case for this interface are iterators that are based on native-resources such as files,
network, or database connections. Clients must call AutoCloseable.close()
after using the iterator.Modifier and Type | Interface and Description |
---|---|
static class |
CloseableIterator.IteratorAdapter<E>
Adapter from
Iterator to CloseableIterator . |
Modifier and Type | Field and Description |
---|---|
static CloseableIterator<?> |
EMPTY_INSTANCE |
Modifier and Type | Method and Description |
---|---|
static <T> CloseableIterator<T> |
adapterForIterator(Iterator<T> iterator) |
static <T> CloseableIterator<T> |
adapterForIterator(Iterator<T> iterator,
AutoCloseable close) |
static <T> CloseableIterator<T> |
empty() |
static <T> CloseableIterator<T> |
flatten(CloseableIterator<T>... iterators) |
static <T> CloseableIterator<T> |
fromList(List<T> list,
java.util.function.Consumer<T> closeNotConsumed) |
static <E> CloseableIterator<E> |
ofElement(E element,
java.util.function.Consumer<E> closeIfNotConsumed) |
static <T> CloseableIterator<T> |
ofElements(java.util.function.Consumer<T> closeNotConsumed,
T... elements) |
forEachRemaining, hasNext, next, remove
close
static final CloseableIterator<?> EMPTY_INSTANCE
@Nonnull static <T> CloseableIterator<T> adapterForIterator(@Nonnull Iterator<T> iterator)
static <T> CloseableIterator<T> adapterForIterator(@Nonnull Iterator<T> iterator, AutoCloseable close)
static <T> CloseableIterator<T> fromList(List<T> list, java.util.function.Consumer<T> closeNotConsumed)
static <T> CloseableIterator<T> flatten(CloseableIterator<T>... iterators)
static <T> CloseableIterator<T> empty()
static <T> CloseableIterator<T> ofElements(java.util.function.Consumer<T> closeNotConsumed, T... elements)
static <E> CloseableIterator<E> ofElement(E element, java.util.function.Consumer<E> closeIfNotConsumed)
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.