Package org.springframework.data.util
Interface CloseableIterator<T>
- Type Parameters:
- T-
- All Superinterfaces:
- AutoCloseable,- Closeable,- Iterator<T>
A 
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.- Since:
- 1.10
- Author:
- Thomas Darimont, Mark Paluch
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()default Spliterator<T>Create aSpliteratorover the elements provided by thisIterator.stream()Return a sequentialStreamwith thisIteratoras its source.Methods inherited from interface java.util.IteratorforEachRemaining, hasNext, next, remove
- 
Method Details- 
closevoid close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
- 
spliteratorCreate aSpliteratorover the elements provided by thisIterator. Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reportsSpliterator.SIZEDand 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 ofIMMUTABLEorCONCURRENT, or be late-binding.The default implementation does not report a size. - Returns:
- a Spliteratorover the elements in thisIterator.
- Since:
- 2.4
 
- 
streamReturn a sequentialStreamwith thisIteratoras its source. The resulting stream callsclose()whenclosed. The resultingStreammust be closed after use, it can be declared as a resource in atry-with-resources statement.This method should be overridden when the spliterator()method cannot return a spliterator that isIMMUTABLE,CONCURRENT, or late-binding. (Seespliterator()for details.)- Returns:
- a sequential Streamover the elements in thisIterator.
- Since:
- 2.4
 
 
-