I have the following domain structure:
abstract class Person { String name; //with getter and setter } class Employer extends Person {} class Employee extends Person {} class Contract { Person contractor; //with getter and setter } class PersonDTO implements Serializable { String name; String type; //type == 'Employee' or 'Employer' } class ContractDTO implements Serializable { PersonDTO contractor; }
Now that I have configured this following bulldozer display:
<mapping> <class-a>Person</class-a> <class-b>PersonDTO</class-b> </mapping> <mapping> <class-a>Employer</class-a> <class-b>PersonDTO</class-b> </mapping> <mapping> <class-a>Contract</class-a> <class-b>ContractDTO</class-b> </mapping>
My problem is matching the Contract.contractor field from B to A, because the Contract.contractor field is an abstract class, and the dozer cannot guess how to initiate it.
So my question is simple: how can I tell dozer that to map the Contract.contractor field, it must create an instance of Employer if type == 'Employer ' and elsewhere in Employee ?
Thank you for your help.
source share