• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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

Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic