In our project we have to map one nested structures of beans onto another. (These are actually JAXB mapped Java-Representations of XML documents that, say, represent an incoming order document.) This has to be mapped onto the quite different order document structure of another system.
What are the options to do this? I would prefer something that fulfills the following requirements:
A promising framework for this is Dozer, but it does not fulfill 1 and 4. Same with JBeanMapper. Just programming it in Java does 4 but not the other requirements; using XSLT fulfills perhaps 2 but nothing else. Do you have better ideas?
ModelMapper is the one library that meets all of your criteria. It offers a mapping API that uses actual code to map properties - so you get code completion. And it offers validation to ensure that all destination properties are mapped. Additionally it offers some things you didn't even know you wanted such as intelligent mapping :)
Check out the ModelMapper homepage for more info:
http://modelmapper.org
Another alternative is MapStruct which generates mapping code at build time, resulting in type-safe mappings which don't require any dependencies at runtime (Disclaimer: I'm the author of MapStruct).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With