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 producesGenericRecordinstances.- Since:
- 5.0
- Author:
- Charles Fleury
-
-
Field Summary
Fields Modifier and Type Field Description protected longcurrentRecordNumberprotected java.util.stream.Stream<T>dataSourceprotected java.util.Iterator<T>iterator
-
Constructor Summary
Constructors Constructor Description StreamRecordReader(java.util.stream.Stream<T> dataSource)Create a newStreamRecordReaderto read records from aStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the reader.voidopen()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 newStreamRecordReaderto read records from aStream.- Parameters:
dataSource- to read records from
-
-
Method Detail
-
open
public void open()
Description copied from interface:RecordReaderOpen the reader.- Specified by:
openin interfaceRecordReader<T>
-
readRecord
public Record<T> readRecord()
Description copied from interface:RecordReaderRead next record from the data source.- Specified by:
readRecordin interfaceRecordReader<T>- Returns:
- the next record from the data source or
nullif the end of the data source is reached
-
close
public void close()
Description copied from interface:RecordReaderClose the reader.- Specified by:
closein interfaceRecordReader<T>
-
-