If each row represented a different ObjectA
then I'd recommend this answer (I initially thought your question was similar to this).
After reading your comments though, that's not going to help. The ObjectA
columns are repeated for every ObjectB
belonging to it.
Super CSV can't combine these for you, so you'll need to store each ObjectA
in a map, e.g.
For each a row read as an
ObjectA
bean (using CsvDozerBeanMapper)Check if there's an
ObjectA
in the Map for the idIf yes, then update it by adding the current
ObjectB
to itIf no, then just add it to the Map
Return the Map's values (the normalized
ObjectA
's).
The downside to having to normalize is that you have to store every ObjectA
in memory.