Mapstruct reference guide MapStruct Beta Reference Guide Table of Contents Preface Introduction Set up Apache Maven Gradle Apache Ant Con ?guration options Using MapStruct on Java De ?ning a mapper Basic mappings Mapping Composition experimental Adding cu

MapStruct Beta Reference Guide Table of Contents Preface Introduction Set up Apache Maven Gradle Apache Ant Con ?guration options Using MapStruct on Java De ?ning a mapper Basic mappings Mapping Composition experimental Adding custom methods to mappers Mapping methods with several source parameters Mapping nested bean properties to current target Updating existing bean instances Mappings with direct ?eld access Using builders Using Constructors Retrieving a mapper The Mappers factory no dependency injection Using dependency injection Injection strategy Data type conversions Implicit type conversions Mapping object references Controlling nested bean mappings Invoking custom mapping method Invoking other mappers Passing the mapping target type to custom mappers Passing context or state objects to custom methods Mapping method resolution Mapping method selection based on quali ?ers Mapping collections Mapping maps C Collection mapping strategies Implementation types used for collection mappings Mapping Streams Mapping Values Mapping enum to enum types Mapping enum-to-String or String-to-enum Custom name transformation Object factories Advanced mapping options Default values and constants Expressions Default Expressions Determining the result type Controlling mapping result for 'null' arguments Controlling mapping result for 'null' properties in bean mappings update mapping methods only Controlling checking result for 'null' properties in bean mapping Source presence checking Exceptions Reusing mapping con ?gurations Mapping con ?guration inheritance Inverse mappings Shared con ?gurations Customizing mappings Mapping customization with decorators Mapping customization with before-mapping and after-mapping methods Using the MapStruct SPI Custom Accessor Naming Strategy Mapping Exclusion Provider Custom Builder Provider Custom Enum Naming Strategy Custom Enum Transformation Strategy Preface This is the reference documentation of MapStruct an annotation processor for generating typesafe performant and dependency-free bean mapping code This guide covers all the functionality provided by MapStruct In case this guide doesn ? t answer all your questions just join the MapStruct Google group to get help You found a typo or other error in this guide Please let us know by opening an issue in the MapStruct GitHub repository or better yet help the community and send a pull request for ?xing Cit This work is licensed under the Creative Commons Attribution- ShareAlike International License Introduction MapStruct is a Java annotation processor for the generation of type-safe bean mapping classes All you have to do is to de ?ne a mapper interface which declares any required mapping methods During compilation MapStruct will generate an implementation of this interface This implementation uses plain Java method invocations for mapping between source and target objects i e no re ection or similar Compared to writing mapping code from hand MapStruct saves time by generating code which is tedious and error- prone to write Following a convention over con ?guration approach MapStruct uses sensible defaults but steps out of your way when it comes to con ?guring or implementing special behavior Compared to dynamic mapping frameworks MapStruct o ?ers the following advantages ? Fast execution by using plain method invocations instead of re ection ? Compile-time type safety Only objects and attributes mapping to each other can be mapped no accidental mapping

  • 24
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Aucune attribution requise
Partager