From 32bf03642c541aeaea450f7f60d3778fbe4c4330 Mon Sep 17 00:00:00 2001 From: Andreas Gudian Date: Mon, 2 Jan 2017 00:17:25 +0100 Subject: [PATCH] #983, #975 rephrase documentation of AfterMapping/BeforeMapping and document @Context usage --- .../main/java/org/mapstruct/AfterMapping.java | 46 +++++++++-------- .../java/org/mapstruct/BeforeMapping.java | 51 ++++++++++--------- 2 files changed, 52 insertions(+), 45 deletions(-) diff --git a/core-common/src/main/java/org/mapstruct/AfterMapping.java b/core-common/src/main/java/org/mapstruct/AfterMapping.java index 21849573a..f6d8350ea 100644 --- a/core-common/src/main/java/org/mapstruct/AfterMapping.java +++ b/core-common/src/main/java/org/mapstruct/AfterMapping.java @@ -23,36 +23,40 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.mapstruct.util.Experimental; - /** * Marks a method to be invoked at the end of a generated mapping method, right before the last {@code return} statement - * of the mapping method. The method can be implemented in an abstract mapper class or be declared in a type (class or - * interface) referenced in {@link Mapper#uses()} in order to be used in a mapping method. + * of the mapping method. The method can be implemented in an abstract mapper class, be declared in a type (class or + * interface) referenced in {@link Mapper#uses()}, or in a type used as {@code @}{@link Context} parameter in order to + * be used in a mapping method. *

- * Only methods with return type {@code void} may be annotated with this annotation. - *

- * If the method has parameters, the method invocation is only generated if all parameters can be assigned by - * the source or target parameters of the mapping method: + * The method invocation is only generated if the return type of the method (if non-{@code void}) is assignable to the + * return type of the mapping method and all parameters can be assigned by the available source, target or + * context parameters of the mapping method: *

*

- * All after-mapping methods that can be applied to a mapping method will be used. Their order is determined by - * their location of definition: - *

+ *
  • Methods declared in one type are used after methods declared in their super-type
  • + * + * Important: the order of methods declared within one type can not be guaranteed, as it depends on the + * compiler and the processing environment implementation. *

    * Example: * @@ -97,8 +101,8 @@ import org.mapstruct.util.Experimental; * * @author Andreas Gudian * @see BeforeMapping + * @see Context */ -@Experimental @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) public @interface AfterMapping { diff --git a/core-common/src/main/java/org/mapstruct/BeforeMapping.java b/core-common/src/main/java/org/mapstruct/BeforeMapping.java index 122b30234..626e918ed 100644 --- a/core-common/src/main/java/org/mapstruct/BeforeMapping.java +++ b/core-common/src/main/java/org/mapstruct/BeforeMapping.java @@ -23,39 +23,42 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.mapstruct.util.Experimental; - /** * Marks a method to be invoked at the beginning of a generated mapping method. The method can be implemented in an - * abstract mapper class or be declared in a type (class or interface) referenced in {@link Mapper#uses()} in order to - * be used in a mapping method. + * abstract mapper class, be declared in a type (class or interface) referenced in {@link Mapper#uses()}, or in a type + * used as {@code @}{@link Context} parameter in order to be used in a mapping method. *

    - * Only methods with return type {@code void} may be annotated with this annotation. - *

    - * If the method has parameters, the method invocation is only generated if all parameters can be assigned by - * the source or target parameters of the mapping method: + * The method invocation is only generated if the return type of the method (if non-{@code void}) is assignable to the + * return type of the mapping method and all parameters can be assigned by the available source, target or + * context parameters of the mapping method: *

    - * If a before-mapping method does not contain a {@code @}{@link MappingTarget} parameter, it is invoked - * directly at the beginning of the applicable mapping method. If it contains a {@code @}{@link MappingTarget} - * parameter, the method is invoked after the target parameter has been initialized in the mapping method. *

    - * All before-mapping methods that can be applied to a mapping method will be used. Their order is determined - * by their location of definition: - *

    + *
  • Methods declared in one type are used after methods declared in their super-type
  • + * + * Important: the order of methods declared within one type can not be guaranteed, as it depends on the + * compiler and the processing environment implementation. *

    * Example: * @@ -101,8 +104,8 @@ import org.mapstruct.util.Experimental; * * @author Andreas Gudian * @see AfterMapping + * @see Context */ -@Experimental @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) public @interface BeforeMapping {