aspose file tools*
The moose likes Java in General and the fly likes Copy value from attribute a1 in class A.java to attribute b1 in class B.java using 0bject mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Copy value from attribute a1 in class A.java to attribute b1 in class B.java using 0bject mapping" Watch "Copy value from attribute a1 in class A.java to attribute b1 in class B.java using 0bject mapping" New topic
Author

Copy value from attribute a1 in class A.java to attribute b1 in class B.java using 0bject mapping

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
Can anyone suggest a pragmatic way (e.g. use of object mappint e.g. Dozer, Smooky etc.) without writing code to copy properties from one object to another when the name of the properties may not match. If names of the properties did match in two objects (A.java and B.java), I could have used copyProperties. I also do not want to write tedious code to copy value of attribute a1 from A.java to value b1 in B.java.

Can you suggest of easy way of doing it using object mapping API of Dozer, Smooky etc.?

This is the problem:

Value of attribute a1 (which has public getter and setter) in class A.java has to to be copied to the value of attribute b1 (which has public getter and setter) of class B.java. As the name of the attributes are different (a1 in A.java and b1 in B.java), I cannot use copyProperties. I also do not want to write tedious Java code to pass the value of a1 of A.java to b1 of B.java.

Is it possible to set up Dozer, Smooky etc. that will copy value of a1 attribute of A.java into b1 attribute of B.java?

If I can do that, I can only write configuration code to do so.

Any advice will be appreciated.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Copy value from attribute a1 in class A.java to attribute b1 in class B.java using 0bject mapping