Interface CloseableIterable<T>

    • Method Detail

      • iterator

        CloseableIterator<T> iterator()
        Returns a closeable iterator over elements of type T.
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Returns:
        an CloseableIterator.
      • withNoopClose

        static <E> CloseableIterable<E> withNoopClose​(java.lang.Iterable<E> iterable)
      • combine

        static <E> CloseableIterable<E> combine​(java.lang.Iterable<E> iterable,
                                                java.io.Closeable closeable)
      • whenComplete

        static <E> CloseableIterable<E> whenComplete​(CloseableIterable<E> iterable,
                                                     java.lang.Runnable onCompletionRunnable)
        Will run the given runnable when Closeable.close() has been called.
        Type Parameters:
        E - The type of the underlying iterable
        Parameters:
        iterable - The underlying CloseableIterable to iterate over
        onCompletionRunnable - The runnable to run after the underlying iterable was closed
        Returns:
        A new CloseableIterable where the runnable will be executed as the final step after Closeable.close() has been called
      • filter

        static <E> CloseableIterable<E> filter​(Counter skipCounter,
                                               CloseableIterable<E> iterable,
                                               java.util.function.Predicate<E> pred)
        Filters the given CloseableIterable and counts the number of elements that do not match the predicate by incrementing the Counter.
        Type Parameters:
        E - The underlying type to be iterated.
        Parameters:
        skipCounter - The Counter instance to increment on each skipped item during filtering.
        iterable - The underlying CloseableIterable to filter.
        Returns:
        A filtered CloseableIterable where the given skipCounter is incremented whenever the predicate does not match.