I\'d like to do something like:
ArrayList objects = new ArrayList();
...
DozerBeanMapper MAPPER = new DozerBeanMapper
You can implement your own mapper class which will extend dozer mapper. Example: Create a interface that adds additional method to dozer mapper:
public interface Mapper extends org.dozer.Mapper {
List mapAsList(Iterable> sources, Class destinationClass);
}
Next step: Write your own Mapper class by implementing above interface.
add below method to your implementation class:
public class MyMapper implements Mapper {
@Override
public List mapAsList(Iterable> sources, Class destinationClass) {
//can add validation methods to check if the object is iterable
ArrayList targets = new ArrayList();
for (Object source : sources) {
targets.add(map(source, destinationClass));
}
return targets;
}
//other overridden methods.
}
Hope this helps