Search code examples
javamergejavabeansdozerapache-commons-beanutils

Java: Merge 2 "beans" to produce a new one


I need to take all the fields and collections from Bean1 and Bean2, sometimes apply some business logic, and produce Bean3 (all beans are hibernate/domain objects of the same type with a reasonably complex graph).

Any thoughts on how to do this? Done something similar in the past?

My ideas:

  1. Dozer (http://dozer.sourceforge.net/)
  2. BeanUtils (http://commons.apache.org/beanutils/)
  3. Handrolled solution
  4. A.N.Other cool solution?

Any recommendations?


Solution

  • Dozer is a nice bean mapping tool. However, it won't perform any business logic, of course.

    I should not be a problem to implement a business logic and to rely on Dozer for bean mapping. This is what I would do.