Java / MapStruct Java Interview questions part 2
What are the types of mapping methods MapStruct can generate?
MapStruct can generate several kinds of mapping methods depending on the method signature you declare in the mapper interface.
| Method style | What it does |
| Bean-to-bean mapping | Maps one object type to another, e.g. CarDto toDto(Car car). |
| Update mapping | Copies values into an existing target passed as @MappingTarget. |
| Iterable/collection mapping | Maps List, Set, or arrays element by element. |
| Map mapping | Maps Map<K,V> to another map type, converting keys/values. |
| Enum mapping | Maps one enum type's constants to another's. |
MapStruct infers which style to generate from the parameter and return types of the abstract method you declare.
More Related questions...