Package org.ojalgo.netio
Class SequencedReader<S,T>
- java.lang.Object
-
- org.ojalgo.netio.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>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ojalgo.netio.FromFileReader
FromFileReader.Builder<F>
-
-
Field Summary
Fields Modifier and Type Field Description private FromFileReader<T>
myCurrent
private java.util.function.Function<S,? extends FromFileReader<T>>
myFactory
private java.util.concurrent.BlockingQueue<S>
mySources
-
Constructor Summary
Constructors Constructor Description SequencedReader(java.util.concurrent.BlockingQueue<S> sources, java.util.function.Function<S,? extends FromFileReader<T>> factory)
Create anAutoSupplier
that will supply items from the containers, one after the other, until all containers are empty.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private void
nextSupplier()
T
read()
Returning null indicates that there are no more items to read.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ojalgo.netio.FromFileReader
drainTo, forEachInBacthes, iterator, map, stream
-
-
-
-
Field Detail
-
myCurrent
private FromFileReader<T> myCurrent
-
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 anAutoSupplier
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 aFile
)T
- The supplier item type (what do the files contain?)- Parameters:
sources
- A set of item containers (could be a set ofFile
: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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceFromFileReader<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 asBufferedReader.readLine()
. All implementations must return null precisely once.- Specified by:
read
in interfaceFromFileReader<S>
-
nextSupplier
private void nextSupplier()
-
-