Package com.chemaxon.calculations.io
Interface CloseableIterator<T>
- Type Parameters:
T
- iterated type
- All Superinterfaces:
AutoCloseable
,Closeable
,Iterator<T>
@Beta
@PublicAPI
@Deprecated(forRemoval=true)
@SubjectToRemoval(date=JAN_01_2025)
public interface CloseableIterator<T>
extends Iterator<T>, Closeable
Deprecated, for removal: This API element is subject to removal in a future version.
Will be removed without replacement.
Closeable iterator.
The iterator requires explicit closing, reaching the last element should not result in implicit close.
IOException
potentially thrown from a delegate Closeable.close()
is expected to be wrapped in to an
IllegalStateException
.
For providing an implementation one can use CloseableIterators.wrap(java.util.Iterator)
,
CloseableIterators.wrap(java.util.Iterator, java.io.Closeable)
or .
Please note that this interface is marked with @Beta annotation, so it can be subject of incompatible changes or removal in later releases.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Deprecated, for removal: This API element is subject to removal in a future version.default CloseableIterator<T>
forward
(long maxItems) Deprecated, for removal: This API element is subject to removal in a future version.Forward this instance by discarding items.default CloseableIterator<T>
limit
(long limit) Deprecated, for removal: This API element is subject to removal in a future version.Return a view limiting the returned element count.default CloseableIterator<T>
Deprecated, for removal: This API element is subject to removal in a future version.Return a view limiting the returned element count.default <U> CloseableIterator<U>
Deprecated, for removal: This API element is subject to removal in a future version.Apply a transformation of the elements of this Iterator.default <U> CloseableIterator<U>
transformIterator
(Function<Iterator<T>, Iterator<U>> processor) Deprecated, for removal: This API element is subject to removal in a future version.Apply a transformation on this Iterator.default <U> CloseableIterator<U>
transformMultipleElements
(Function<Iterator<T>, U> constructNext) Deprecated, for removal: This API element is subject to removal in a future version.Transform multiple elements into a single element.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
close
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IllegalStateException
-
transform
Deprecated, for removal: This API element is subject to removal in a future version.Apply a transformation of the elements of this Iterator.- Type Parameters:
U
- Transformed type- Parameters:
transformation
- Transformation to apply on returned elements- Returns:
- Transformed view of this Iterator
-
forward
Deprecated, for removal: This API element is subject to removal in a future version.Forward this instance by discarding items.- Parameters:
maxItems
- Item count to discard.- Returns:
- Reference to
this
instance
-
limit
Deprecated, for removal: This API element is subject to removal in a future version.Return a view limiting the returned element count.- Parameters:
limit
- Max number of elements returned by the view- Returns:
- limiting view
-
limit
Deprecated, for removal: This API element is subject to removal in a future version.Return a view limiting the returned element count.- Parameters:
limit
- Max number of elements returned by the viewafterLimitReachedOrNull
- Optional callback to invoke when limit reached. Will be invoked fromIterator.hasNext()
the first time it returnsfalse
. The role of this callback is to optionally sign that reading elements stopped because of reaching the specified limit. When no call made toIterator.hasNext()
after reaching this limit no callback invocation will be made. Also when whenIterator.next()
invoked after reaching the limit it will throw aNoSuchElementException
but no callback invocation will be made.- Returns:
- limiting view
-
transformIterator
Deprecated, for removal: This API element is subject to removal in a future version.Apply a transformation on this Iterator.- Type Parameters:
U
- Type of transformed elements- Parameters:
processor
- Function to call on this instance- Returns:
- Transformed Iterator
-
transformMultipleElements
Deprecated, for removal: This API element is subject to removal in a future version.Transform multiple elements into a single element.- Type Parameters:
U
- Type of transformed elements- Parameters:
constructNext
- Function to create next element- Returns:
- Transformed Iterator
-