Package org.mapstruct
Annotation Type InheritConfiguration
-
@Target(METHOD) @Retention(CLASS) public @interface InheritConfigurationAdvises the code generator to apply the configuration (as given viaMapping,IterableMappingetc.) 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);
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringnameThe name of the mapping method to inherit the mappings from.
-