How do you map a single field into a List
/ Collection
in Dozer?
class SrcFoo {
private String id;
private List<SrcBar> bars;
}
class SrcBar {
private String name;
}
Here are my destination objects:
class DestFoo {
private List<DestBar> destBars;
}
class DestBar {
private String fooId; // Populated by SrcFoo.id
private String barName;
}
I want all DestBar.fooId
(entire list of DestBars) to be populated with SrcFoo.id
This question is similar to this one posted here, expect I want to map my single field to every item in the list. Dozer: map single field to Set
I tried the following, but it only populated DestBar.fooId
for the first item in the list.
<mapping>
<class-a>SrcFoo</class-a>
<class-b>DestFoo</class-b>
<field>
<a>bars</a>
<b>destBars</b>
</field>
<field>
<a>id</a>
<b>destBars.fooId</b> <!-- same affect as destBars[0].fooId ? -->
</field>
</mapping>