Hello,
There is a limitation on adding CsvRecurse on multiple fields with the same type in one bean, but I want to process recursively each of them but with specific unique headers.
public class ExampleBean {
private String simple;
@CsvRecurse
private UserInfo createdBy;
@CsvRecurse
private UserInfo modifiedBy;
@CsvRecurse
private UserInfo owner;
}
public class UserInfo {
private String firstName;
private String lastName;
@CsvBindByName
private String username;
private String primaryEmail;
}
I expect the input to be mapped to this bean could look like this:
simple,createdBy username,modifiedBy username,owner username
simple value,johndoe@mail.com, mrstone@mail.com, mrs.mason@mail.com
but I got an error: "recursive.type.encountered.twice".
Thanks.
While I understand your desire, there is a reason for this limitation. Using your example, you annotated UserInfo.username with a simple CsvBindByName, which means opencsv expects the input field in the CSV file to be named "username." You cannot now re-annotate the same bean member with the name of a different field from the CSV input.