Interface CloseableIterator<T>
- All Superinterfaces:
AutoCloseable, Closeable, Iterator<T>
- All Known Subinterfaces:
CloseableTribbleIterator<T>, SAMRecordIterator, VCFIterator
- All Known Implementing Classes:
AbstractLocusIterator, AsyncBufferedIterator, BAMFileReader.BAMQueryFilteringIterator, CRAMIterator, DelegatingIterator, DownsamplingIterator, DuplicateSetIterator, EdgeReadIterator, FilteringIterator, FilteringIterator, FilteringSamIterator, FilteringVariantContextIterator, MergingIterator, MergingSamRecordIterator, PeekableIterator, SamLocusIterator, SamPairUtil.SetMateInfoIterator, SamReader.AssertingIterator, SAMRecordPrefetchingIterator
This interface is used by iterators that use releasable resources during iteration.
The consumer of a CloseableIterator should ensure that the close() method is always called,
for example by putting such a call in a finally block. Two conventions should be followed
by all implementors of CloseableIterator:
1) The close() method should be idempotent: calling close() twice should have no effect.
2) When hasNext() returns false, the iterator implementation should automatically close itself.
The latter makes it somewhat safer for consumers to use the for loop syntax for iteration:
for (Type obj : getCloseableIterator()) { ... }
-
Method Summary
Methods inherited from interface Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
close
void close()Should be implemented to close/release any underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
toList
-
stream
-