Class Closeables


  • public class Closeables
    extends Object
    This class is used solely for the purpose of converting classes only in core to corresponding closeable variants.
    Since:
    9.3
    Author:
    wburns
    • Method Detail

      • iterator

        public static <E> CloseableIterator<E> iterator​(org.reactivestreams.Publisher<E> publisher,
                                                        int fetchSize)
        Converts a Publisher to a CloseableIterator by utilizing items fetched into an array and refetched as they are consumed from the iterator. The iterator when closed will also close the underlying Subscription when subscribed to the publisher.
        Type Parameters:
        E - value type
        Parameters:
        publisher - the publisher to convert
        fetchSize - how many entries to hold in memory at once in preparation for the iterators consumption
        Returns:
        an iterator that when closed will cancel the subscription