Map me if you can! Painless bean mappings with MapStruct
|Java Language & Server Side|
The mapping between different data models is a common but unpleasant task for developers, e.g. when propagating data from an internal domain model to the elements of a REST facade, UI layer or external web service.
Writing conversion code by hand is tedious and error-prone, while reflection-based solutions suffer from poor performance and the lack of type-safety. MapStruct takes a fresh look at the issue and generates mapping code at compile time, based on Java interface definitions. The resulting code is type-safe and super-fast, has no dependencies and is easy to understand (and debug, if ever needed). Providing many type conversions out of the box, MapStruct also allows you to customize and amend mappings as needed.
We'll discuss typical mapping problems and their solution with MapStruct. You'll see the generator in action (CLI and IDE) and quickly forget about the pain bean mappings used to give you in the past.
Gunnar Morling is a software engineer and open-source enthusiast by heart. He’s leading the Debezium project, a tool for change data capture (CDC). As part of the Hibernate team, he contributes to Hibernate Validator, Search and OGM. Gunnar is the spec lead for Bean Validation 2.0 (JSR 380) and the founder of the MapStruct project. Prior to joining Red Hat, he worked on a wide range of Java EE projects in the logistics and retail industries. He’s based in Hamburg, Germany.