Interface CloseableIterator<T>

    • Method Detail

      • transform

        default <U> CloseableIterator<U> transform​(Function<T,​U> transformation)
        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

        default CloseableIterator<T> forward​(long maxItems)
        Forward this instance by discarding items.
        Parameters:
        maxItems - Item count to discard.
        Returns:
        Reference to this instance
      • limit

        default CloseableIterator<T> limit​(long limit)
        Return a view limiting the returned element count.
        Parameters:
        limit - Max number of elements returned by the view
        Returns:
        limiting view
      • limit

        default CloseableIterator<T> limit​(long limit,
                                           Consumer<Long> afterLimitReachedOrNull)
        Return a view limiting the returned element count.
        Parameters:
        limit - Max number of elements returned by the view
        afterLimitReachedOrNull - Optional callback to invoke when limit reached. Will be invoked from Iterator.hasNext() the first time it returns false. The role of this callback is to optionally sign that reading elements stopped because of reaching the specified limit. When no call made to Iterator.hasNext() after reaching this limit no callback invocation will be made. Also when when Iterator.next() invoked after reaching the limit it will throw a NoSuchElementException but no callback invocation will be made.
        Returns:
        limiting view
      • transformIterator

        default <U> CloseableIterator<U> transformIterator​(Function<Iterator<T>,​Iterator<U>> processor)
        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

        default <U> CloseableIterator<U> transformMultipleElements​(Function<Iterator<T>,​U> constructNext)
        Transform multiple elements into a single element.
        Type Parameters:
        U - Type of transformed elements
        Parameters:
        constructNext - Function to create next element
        Returns:
        Transformed Iterator