I would like to share some experiments with the DozerConverter API.
I created a test case in a maven project attached.
I would like to map an AfterSaleServiceAction bean to a HumanInteraction bean.
The need is simple, if an AfterSaleServiceAction has a customer and an employee associated, just map it to two Interviewer's and Interviewee's identification beans.
As Customer and Employee don't have the same fields for names, I have to map each beans with a custom converter.
As the Identification is composed of a field that must contain the fullname, I created an abstract converter, and two subclass containing only the fullname construction logic.
When I try my test case, Dozer throws an exception when instantiation the subclass converter:
org.dozer.MappingException: java.lang.InstantiationException: com.sample.dozer.converter.EmployeeIdentificationConverter
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:82)
at org.dozer.util.ReflectionUtils.newInstance(ReflectionUtils.java:366)
at org.dozer.MappingProcessor.mapUsingCustomConverter(MappingProcessor.java:1015)
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:364)
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:307)
at org.dozer.MappingProcessor.map(MappingProcessor.java:267)
at org.dozer.MappingProcessor.mapToDestObject(MappingProcessor.java:216)
at org.dozer.MappingProcessor.createByCreationDirectiveAndMap(MappingProcessor.java:196)
at org.dozer.MappingProcessor.mapGeneral(MappingProcessor.java:170)
at org.dozer.MappingProcessor.map(MappingProcessor.java:104)
at org.dozer.MappingProcessor.map(MappingProcessor.java:99)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:120)
at com.sample.dozer.service.HumanInteractionServiceStub.from(HumanInteractionServiceStub.java:13)
at com.sample.dozer.service.HumanInteractionServiceStubTest.stubTestNotInitializedResources(HumanInteractionServiceStubTest.java:35)
...
Caused by: java.lang.InstantiationException: com.sample.dozer.converter.EmployeeIdentificationConverter
at java.lang.Class.newInstance(Class.java:427)
at org.dozer.util.ReflectionUtils.newInstance(ReflectionUtils.java:364)
... 36 more
Caused by: java.lang.NoSuchMethodException: com.sample.dozer.converter.EmployeeIdentificationConverter.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
... 37 more