diff --git a/core-jdk8/src/main/java/org/mapstruct/Mapping.java b/core-jdk8/src/main/java/org/mapstruct/Mapping.java index c37abbeb1..22aa0d28b 100644 --- a/core-jdk8/src/main/java/org/mapstruct/Mapping.java +++ b/core-jdk8/src/main/java/org/mapstruct/Mapping.java @@ -37,12 +37,17 @@ import java.util.Date; public @interface Mapping { /** - * The source name of the configured property as defined by the JavaBeans specification. If used to map an enum - * constant, the name of the constant member is to be given. + * The source to use for this Mapping. This can either be: + *
    + *
  1. The source name of the configured property as defined by the JavaBeans specification.
  2. + *
  3. When used to map an enum constant, the name of the constant member is to be given<./li>. + *
+ * Either this attribute or {@link #expression()} may be specified for a given mapping, but not both at the same + * time. * - * @return The source name of the configured property or enum constant + * @return The source name of the configured property or enum constant. */ - String source(); + String source() default ""; /** * The target name of the configured property as defined by the JavaBeans specification. Defaults to the source name @@ -59,4 +64,16 @@ public @interface Mapping { * @return A date format string as processable by {@link SimpleDateFormat}. */ String dateFormat() default ""; + + /** + * A constant {@link String} expression based on which the specified target property is to be set. If the designated + * target property is not of type {@code String}, the value will be converted by applying a matching conversion + * method or built-in conversion. + *

+ * Either this attribute or {@link #source()} may be specified for a given mapping, but not both at the same time. + * If this attribute is given, the target property must be specified via {@link #target()}. + * + * @return A constant {@code String} expression specifying the value for the designated target prperty + */ + String expression() default ""; } diff --git a/core/src/main/java/org/mapstruct/Mapping.java b/core/src/main/java/org/mapstruct/Mapping.java index 1b156f53f..63fed1607 100644 --- a/core/src/main/java/org/mapstruct/Mapping.java +++ b/core/src/main/java/org/mapstruct/Mapping.java @@ -40,6 +40,8 @@ public @interface Mapping { *

  • The source name of the configured property as defined by the JavaBeans specification.
  • *
  • When used to map an enum constant, the name of the constant member is to be given<./li>. * + * Either this attribute or {@link #expression()} may be specified for a given mapping, but not both at the same + * time. * * @return The source name of the configured property or enum constant. */ @@ -62,10 +64,14 @@ public @interface Mapping { String dateFormat() default ""; /** - * {@link String} expression that uses available mappings and conversion to set the designated target property to - * the provided expression. + * A constant {@link String} expression based on which the specified target property is to be set. If the designated + * target property is not of type {@code String}, the value will be converted by applying a matching conversion + * method or built-in conversion. + *

    + * Either this attribute or {@link #source()} may be specified for a given mapping, but not both at the same time. + * If this attribute is given, the target property must be specified via {@link #target()}. * - * @return expression + * @return A constant {@code String} expression specifying the value for the designated target prperty */ String expression() default ""; }