I don't want my bean to have a dependency on OpenCSV or the custom converter that will populate it. Can I somehow apply custom converters on a per column basis? thinking something roughly like this:
class Person {
String name;
LocalDate birthday
}
Map<string, string=""> colsToFields = new HashMap<>();
colsToFields.put("User Name", "name");
colsToFields.put("User Birthday", "birthday");</string,>
Map<string, string=""> colsToConverter = new HashMap<>();
colsToConverter.put("User Name", NameConverter.class);
colsToConverter.put("User Birthday", MyDateConverter.class);</string,>
HeaderColumnNameTranslateMappingStrategy<person> strategy = new HeaderColumnNameTranslateMappingStrategy<person>();
strategy.setType(Person.class);
strategy.setColumnMapping(colsToFields);
strategy.setConverterMapping(colsToConverter);</person></person>
Is there already some way to do this? Thanks
Sorry it lookslike some weird text was inserted in my code by the editor. You get the idea.
There is currently no way to do that. I personally am not very interested in implementing it. Perhaps someone else is. However, for anyone wishing to submit a patch or pull request, I would expect a full API that would make it possible to do everything opencsv currently does without the use of annotations.
I'm curious: would an external XML configuration file that tells opencsv how to bind to a bean be good for you?
I think it would be cool if users had the choice of defining the bindgings in XML or in a Java class. Personally, I like to keep everything in Java.
+1 would love to have this feature where you could avoid annotations and specify the same values on column mappers
I am no longer actively developing in the project.