Menu

#160 add prefix to CsvRecurse

open
nobody
None
5
2023-07-10
2023-04-04
No

it would be great if we could have prefix to CsvRecurse, to be able to have the same name of field in the inner and outer entity.
I fI take the exaple from the doc we could have something like

public class Book {
    @CsvBindByName
    private String title;

    @CsvRecurse(prefix = "author ")
    private Author author;

    @CsvRecurse
    private PublishingInformation publish;

    // Accessor methods go here.
}

public class Author {
    @CsvBindByName(column = "given name")
    private String givenName;

    @CsvBindByName(column = "surname")
    private String surname;

    // Accessor methods go here.
}

this wouldn't be very hard to implement, and willing to make a PR

Discussion

  • Youssef El Houti

    Also, having an include and/or exclude property in the annotation would allow exporting recursive entities.

     
  • Scott Conway

    Scott Conway - 2023-07-10

    Hello Youssef! My apologies for taking so long to respond but work and family have conspired to keep me away from open source for most of this year.

    If you wish to create a PR for the above feature go right ahead! as you can see from my response time it may be a while for me to get to it but I will.

    Take a look at https://sourceforge.net/p/opencsv/wiki/Submissions/ and don't let it put you off. I am actually quite liberal about what I accept as long as it does not break backwards compatibility - namely all current tests pass and you have submitted unit tests that documents your code features. In your specific case I ask you to update the asciidoc documentation on annotations as well as there is a lot of existing documentation on the CSVBindByName and we would like to keep that up to date. That is in the code but you can find a live representatoin at https://opencsv.sourceforge.net/index.html#annotations_2

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.