Multiple column names
Brought to you by:
aruckerjones,
sconway
Hello,
we have to define multiple names for one column (one word: customers :D ), so I would like to see the feature to define multiple column names in the annotations. I would suggest something like following:
@CsvBindByName(column = "columnName1|columnName2|columnA|columnB")
public Long example;
If this is already possible somehow, I apologize for opening a new ticket for this feature.
regards
Patrick
Well hopefully its multiple customers and each one has their own terminology not one customer that says I am going to send you three columns and they can all map to this field.
I am not sure about the CsvBindByName but the HeaderColumnNameTranslateMappingStrategy can allow this as the below test demonstrates. But be carefult because the results could be undefined if you get cute and try multithreading.
Unless you have multiple customers whose different spreadsheets do not overlap I would recommend you create what I call a DataTransferObject (DTO) which would be an intermediate object that has all the fields in it and then in either the DTO or a separate factory object (preferred) have the logic that would take the DTO and produce your desired object so you can take care of the overlapping null/empty string or give an error if the customer decided to fill in both overlapping columns with the different values.
Regards
Scott Conway :)
Last edit: Scott Conway 2017-12-04
Scott's suggestion is a natural and functional one. Still, I can understand the need to some extent. Let me ruminate on this a while before we make any decisions.
I did some thinking on this. The biggest problem I see here is that it cannot possibly be round-trip equivalent. That is, we could possibly implement a reading method that takes alternative header names, but what do we do on writing? We can't guess which one is correct.
So, I have two further suggestions for you:
If you have question, suggestions, or further comments, feel free to write back, even though I'm closing this ticket.