Package org.mapstruct
Annotation Type InheritConfiguration
-
@Target(METHOD) @Retention(CLASS) public @interface InheritConfiguration
Advises the code generator to apply the configuration (as given viaMapping
,IterableMapping
etc.) from another mapping method (declared on the same mapper type) or prototype method (declared on a mapper config class referenced viaMapper.config()
) to the annotated method as well.If no method can be identified unambiguously as configuration source (i.e. several candidate methods with matching source and target type exist), the name of the method to inherit from must be specified via
name()
.Mapping.expression()
,Mapping.constant()
,Mapping.defaultExpression()
andMapping.defaultValue()
are not inverse inheritedA typical use case is annotating an update method so it inherits all mappings from a corresponding "standard" mapping method:
@Mappings({ @Mapping(target="make", source="brand"), @Mapping(target="seatCount", source="numberOfSeats") }) CarDto carToCarDto(Car car); @InheritConfiguration void updateCarDto(Car car, @MappingTarget CarDto carDto);
- Author:
- Sjaak Derksen
-
-
Element Detail
-
name
String name
The name of the mapping method to inherit the mappings from. Needs only to be specified in case more than one method with matching source and target type exists.- Returns:
- The name of the mapping method to inherit the mappings from.
- Default:
- ""
-
-