Class SequencedReader<S,​T>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Iterable<T>, FromFileReader<T>

    final class SequencedReader<S,​T>
    extends java.lang.Object
    implements FromFileReader<T>
    • Constructor Summary

      Constructors 
      Constructor Description
      SequencedReader​(java.util.concurrent.BlockingQueue<S> sources, java.util.function.Function<S,​? extends FromFileReader<T>> factory)
      Create an AutoSupplier that will supply items from the containers, one after the other, until all containers are empty.
    • Field Detail

      • myFactory

        private final java.util.function.Function<S,​? extends FromFileReader<T>> myFactory
      • mySources

        private final java.util.concurrent.BlockingQueue<S> mySources
    • Constructor Detail

      • SequencedReader

        SequencedReader​(java.util.concurrent.BlockingQueue<S> sources,
                        java.util.function.Function<S,​? extends FromFileReader<T>> factory)
        Create an AutoSupplier that will supply items from the containers, one after the other, until all containers are empty. You can create multiple such suppliers sharing the same queue of containers.
        Type Parameters:
        S - The type of some sort of item container (maybe a File)
        T - The supplier item type (what do the files contain?)
        Parameters:
        sources - A set of item containers (could be a set of File:s)
        factory - A factory method that can take one of the "containers" and return an item supplier.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface FromFileReader<S>
        Throws:
        java.io.IOException
      • read

        public T read()
        Description copied from interface: FromFileReader
        Returning null indicates that there are no more items to read. That's the same behaviour as BufferedReader.readLine(). All implementations must return null precisely once.
        Specified by:
        read in interface FromFileReader<S>
      • nextSupplier

        private void nextSupplier()