Copy value from attribute a1 in class A.java to attribute b1 in class B.java using 0bject mapping
posted 4 years ago
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.