I try to map a nested bean structure with openCSV. I found the @CsvRecurse annotation, but this does not seem to work if a nested bean is used multiple times.
What options do I have to solve this?
Example (adapted from the docs linked above)
Data structure to map :
title,author1 given name,author1 surname,author2 given name,author2 surname
Space Opera 2.0,Andrew,Jones,Hanna,Smith
I would like to get the following beans
public class Book {
@CsvBindByName
private String title;
// TODO: How to bind author1 and author2?
private Author author1;
private Author author2;
// Accessor methods go here.
}
public class Author {
// TODO: can I somehow use a prefix/Regex for the column here to differentiate between author1 and author2?
@CsvBindByName(column = "author[1/2] given name")
private String givenName;
@CsvBindByName(column = "author[1/2] surname")
private String surname;
// Accessor methods go here.
}