Package org.jeasy.batch.core.reader
Class StreamRecordReader<T>
- java.lang.Object
-
- org.jeasy.batch.core.reader.StreamRecordReader<T>
-
- Type Parameters:
T
- Type of elements in the stream.
- All Implemented Interfaces:
RecordReader<T>
public class StreamRecordReader<T> extends java.lang.Object implements RecordReader<T>
Reader that reads records form aStream
. This reader producesGenericRecord
instances.- Since:
- 5.0
- Author:
- Charles Fleury
-
-
Field Summary
Fields Modifier and Type Field Description protected long
currentRecordNumber
protected java.util.stream.Stream<T>
dataSource
protected java.util.Iterator<T>
iterator
-
Constructor Summary
Constructors Constructor Description StreamRecordReader(java.util.stream.Stream<T> dataSource)
Create a newStreamRecordReader
to read records from aStream
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the reader.void
open()
Open the reader.Record<T>
readRecord()
Read next record from the data source.
-
-
-
Constructor Detail
-
StreamRecordReader
public StreamRecordReader(java.util.stream.Stream<T> dataSource)
Create a newStreamRecordReader
to read records from aStream
.- Parameters:
dataSource
- to read records from
-
-
Method Detail
-
open
public void open()
Description copied from interface:RecordReader
Open the reader.- Specified by:
open
in interfaceRecordReader<T>
-
readRecord
public Record<T> readRecord()
Description copied from interface:RecordReader
Read next record from the data source.- Specified by:
readRecord
in interfaceRecordReader<T>
- Returns:
- the next record from the data source or
null
if the end of the data source is reached
-
close
public void close()
Description copied from interface:RecordReader
Close the reader.- Specified by:
close
in interfaceRecordReader<T>
-
-