factor App.java into domain classes

This commit is contained in:
2018-04-06 18:24:19 -07:00
parent 64a13a3727
commit aff8fb8404
11 changed files with 382 additions and 61 deletions

View File

@ -0,0 +1,32 @@
import java.io.File;
import java.io.IOException;
import com.espertech.esper.client.EPServiceProvider;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
public class CSVReader /*implements TickStreamReader*/ {
File file;
public CSVReader(File file) {
this.file = file;
}
public void run(TickProcessor processor) {
CsvMapper mapper = new CsvMapper();
CsvSchema schema = mapper.schemaFor(TrueFXTick.class);
try {
MappingIterator<TrueFXTick> it = mapper.readerFor(TrueFXTick.class).with(schema).readValues(file);
while (it.hasNextValue()) {
TrueFXTick value = it.nextValue();
processor.process(value);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}