I'm using google's CSVReader which requires a class name to create a parser. Using the parser, I'm reading a CSV file into a list.
Consider this code:
ValueProcessorProvider provider = new ValueProcessorProvider();
CSVEntryParser<A> entryParser = new AnnotationEntryParser<A>(A.class, provider);
CSVReader<A> newExternalFileCSVReader =
new CSVReaderBuilder<A>(m_NewExternalFile).entryParser((CSVEntryParser<A>) entryParser).strategy(new CSVStrategy(',', '"', '#', true, true)).build();
List<A> m_NewExternalFileData = newExternalFileCSVReader.readAll();
With this code, I can read a CSV file that is specific to class A.
I have several other classes: B,C,D, which all uses the same code above, just with their respective class.
Can there be a function where I'll pass the class name as String which can instantiate a CSVReader / parser's based on the String input name? where instead of having to create 3 different code sections (for classes B,C,D), I can use the same one, just input the relevant class name?