0

I'm trying to map properties of beans, which are in different packages, using dozer eg:

<mapping> 
 <class-a>com.naeem.schema.basictypes.Birth</class-a> 
 <class-b>com.naeem.schema.forms.n840.DateStore</class-b> 
  <field>
   <a>countryOfBirth</a>
   <b>countryOfBirth</b> 
 </field> 
</mapping>

is this possible in dozer. Thanks

naeem a
  • 1
  • 1

1 Answers1

0

Yes, Its possible in dozer. By default, dozer will map all property from source object to same name property in destination object. So in your case both the class has a property countryOfBirth of same name. So you dont even have to write mapping file. Following will be suffice :

DozerMapper mapper = new DozerMapper();
Birth birth = new Birth();
//set different fields of birth object
DateStore dateStore =  new DateStore();
mapper.map(birth,dateStore);

Or,ulternatively,

DozerMapper mapper = new DozerMapper();
Birth birth = new Birth();
//set different fields of birth object
DateStore dateStore =  mapper.map(birth,DateStore.class);
Priyank Doshi
  • 12,895
  • 18
  • 59
  • 82