@Target(value=METHOD) @Retention(value=CLASS) public @interface InheritConfiguration
Mapping
, IterableMapping
etc.)
from another mapping method (declared on the same mapper type) or prototype method (declared on a mapper config class
referenced via Mapper.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()
and
Mapping.defaultValue()
are not inverse inherited
A 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);
public abstract String name
Copyright © 2012-2021 MapStruct Authors; All rights reserved. Released under the Apache Software License 2.0.