Skip to content

MapStruct is a code generator that greatly simplifies the implementation of mappings between Java bean types based on a convention over configuration approach. The generated mapping code uses plain method invocations and thus is fast, type-safe and easy to understand.

dberna2/mapstruct-field-mappings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mapstruct-field-mappings

MapStruct is a code generator that simplifies the implementation of mappings between java objects. The great virtue of this code generator, is to generate the mapping code in time of complication and not of execution since as we know the use of reflection as it uses dozzer or orikaMapper is something expensive to do and more if it is done again and again once for each mapping that is needed. Having the code already generated these tasks will be much faster. I took a look at the code that it generates and it did not seem at all bad to me the way it does, since the manuel way that is done as a developer is very similar

CustomerDtoDefintion

CustomerDtoDefintion

CustomerDtoDefintion

Requisitos

Class diagram

CustomerDtoDefintion

Car mapper example

  • Automatic mapping attributes with same name and type
  • Mapping attributes with same type and different name: ignoreField->fieldToIgnore (You only have to declare in CarMapper)
  • Ignore property wont be mapped (ignore=true)
  • @DecoratedWith(CarMapperDecorator.class) will allow to overwrite any value.

CustomerDtoDefintion

CustomerDtoDefintion

  • Note: In this case I only change the person name.

CustomerDtoDefintion

-InheritInverseConfiguration In this last image we see the notation InheritInverseConfiguration, in this case the I use to create the same configuration of CarDTO to Car or Car to CarDTO

About

MapStruct is a code generator that greatly simplifies the implementation of mappings between Java bean types based on a convention over configuration approach. The generated mapping code uses plain method invocations and thus is fast, type-safe and easy to understand.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages