#1983 javadoc and doc on @ignore in @InheritInverseConfituration (#1986)

This commit is contained in:
Sjaak Derksen 2019-12-23 20:41:38 +01:00 committed by GitHub
parent 84062bf78f
commit c153c8bf5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -18,6 +18,10 @@ import java.lang.annotation.Target;
* 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 {@link #name()}.
* <p>
* {@link Mapping#expression()}, {@link Mapping#constant()}, {@link Mapping#defaultExpression()} and
* {@link Mapping#defaultValue()} are not inverse inherited
*
* <p>
* A typical use case is annotating an update method so it inherits all mappings from a corresponding "standard" mapping
* method:
*

View File

@ -21,9 +21,12 @@ import java.lang.annotation.Target;
* <p>
* If more than one matching inverse method exists, the name of the method to inherit the configuration from must be
* specified via {@link #name()}
* <p>
* {@link Mapping#expression()}, {@link Mapping#constant()}, {@link Mapping#defaultExpression()} and
* {@link Mapping#defaultValue()} are not inverse inherited
*
* <p>
* <strong>Example</strong>
* <strong>Examples</strong>
* </p>
* <pre><code class='java'>
* &#64;Mapper
@ -56,7 +59,21 @@ import java.lang.annotation.Target;
* }
* }
* </code></pre>
* <p>
* <pre><code class='java'>
* &#64;Mapper
* public interface CarMapper {
*
* &#64;Mapping( target = "seatCount", source = "numberOfSeats")
* &#64;Mapping( target = "enginePower", source = "engineClass", ignore=true) // NOTE: source specified as well
* CarDto carToDto(Car car);
*
* &#64;InheritInverseConfiguration
* &#64;Mapping(target = "numberOfSeats", ignore = true)
* // no need to specify a mapping with ignore for "engineClass": specifying source above will assume
* Car carDtoToCar(CarDto carDto);
* }
* </code></pre>
* @author Sjaak Derksen
*/
@Target(ElementType.METHOD)

View File

@ -78,13 +78,15 @@ If multiple methods qualify, the method from which to inherit the configuration
Configurations are inherited transitively. So if method `C` defines a mapping `@Mapping( target = "x", ignore = true)`, `B` defines a mapping `@Mapping( target = "y", ignore = true)`, then if `A` inherits from `B` inherits from `C`, `A` will inherit mappings for both property `x` and `y`.
Expressions and constants are excluded (silently ignored) in `@InheritInverseConfiguration`.
`@Mapping#expression`, `@Mapping#defaultExpression`, `@Mapping#defaultValue` and `@Mapping#constant` are excluded (silently ignored) in `@InheritInverseConfiguration`.
`@Mapping#ignore` is only applied when `@Mapping#source` is also present in `@InheritInverseConfiguration`.
Reverse mapping of nested source properties is experimental as of the 1.1.0.Beta2 release. Reverse mapping will take place automatically when the source property name and target property name are identical. Otherwise, `@Mapping` should specify both the target name and source name. In all cases, a suitable mapping method needs to be in place for the reverse mapping.
[NOTE]
====
`@InheritConfiguration` or `@InheritInverseConfiguration` cannot refer to methods in a used mapper.
`@InheritInverseConfiguration` cannot refer to methods in a used mapper.
====
[[shared-configurations]]