This is actually answered in their FAQ, but it's all the way down in the advanced section for some reason. I don't think this is an advanced topic, I think it's a common thing to want to do. You do it with a collection hint.
When mapping collections, how do I tell Dozer what type of data objects I want in the destination collection?
Hints are supported to
handle this use case. Hints are not required if you are using JDK 1.5
Generics because the types can be auto detected by Dozer. But if you
are not using generics, to convert a Collection/Array to a
Collection/Array with different type objects you can specify a Hint to
let Dozer know what type of objects you want created in the
destination list. If a Hint is not specified for the destination
field, then the destination Collection will be populated with objects
that are the same type as the elements in the src Collection.
<field>
<a>someList</a>
<b>otherList</b>
<b-hint>org.dozer.vo.TheFirstSubClassPrime</b-hint>
</field>
That answer shows you how to do it in xml. Here's how you can do it in java code with a Mapping:
import org.dozer.loader.api.BeanMappingBuilder;
import static org.dozer.loader.api.FieldsMappingOptions.hintB;
public class Mapping extends BeanMappingBuilder {
@Override
protected void configure() {
mapping(Subject.class, JsonSubject.class)
.fields("names", "names", hintB(JsonName.class));
}
}
The hint tells dozer, "this list of A's should be converted to a list JsonName instances". Here's how you add this mapping to your mapper:
mapper = new DozerBeanMapper();
mapper.addMapping(new Mapping());