diff --git a/core-jdk8/src/main/java/org/mapstruct/Mapping.java b/core-jdk8/src/main/java/org/mapstruct/Mapping.java index 9cc7e2b45..0794e4520 100644 --- a/core-jdk8/src/main/java/org/mapstruct/Mapping.java +++ b/core-jdk8/src/main/java/org/mapstruct/Mapping.java @@ -92,14 +92,29 @@ public @interface Mapping { String constant() default ""; /** - * An expression {@link String} based on which the specified target property is to be set. The format is determined - * by a type of expression. For instance: - * {@code expression = "java(new org.example.TimeAndFormat( s.getTime(), s.getFormat() ))")} will insert the java - * expression in the designated {@link #target()} property. + * An expression {@link String} based on which the specified target property is to be set. + *
+ * Currently, Java is the only supported "expression language" and expressions must be given in form of Java
+ * expressions using the following format: {@code java(
- * Either this attribute or {@link #source()} or {@link #constant()} may be specified for a given mapping.
*
- * @return A constant {@code String} constant specifying the value for the designated target property
+ *
+ * will cause the following target property assignment to be generated:
+ *
+ * {@code targetBean.setSomeProp( new TimeAndFormat( s.getTime(), s.getFormat() ) )}.
+ *
+ * Any types referenced in expressions must be given via their fully-qualified name. Alternatively, types can be
+ * imported via {@link Mapper#imports()}.
+ *
+ * Either this attribute, {@link #source()} or {@link #constant()} may be specified for a given mapping.
+ *
+ * @return An expression specifying the value for the designated target property
*/
String expression() default "";
diff --git a/core/src/main/java/org/mapstruct/Mapping.java b/core/src/main/java/org/mapstruct/Mapping.java
index ce367def6..c4226d406 100644
--- a/core/src/main/java/org/mapstruct/Mapping.java
+++ b/core/src/main/java/org/mapstruct/Mapping.java
@@ -90,14 +90,29 @@ public @interface Mapping {
String constant() default "";
/**
- * An expression {@link String} based on which the specified target property is to be set. The format is determined
- * by a type of expression. For instance:
- * {@code expression = "java(new org.example.TimeAndFormat( s.getTime(), s.getFormat() ))")} will insert the java
- * expression in the designated {@link #target()} property.
+ * An expression {@link String} based on which the specified target property is to be set.
+ *
+ * Currently, Java is the only supported "expression language" and expressions must be given in form of Java
+ * expressions using the following format: {@code java(
- * Either this attribute or {@link #source()} or {@link #constant()} may be specified for a given mapping.
*
- * @return A constant {@code String} constant specifying the value for the designated target property
+ *
+ * will cause the following target property assignment to be generated:
+ *
+ * {@code targetBean.setSomeProp( new TimeAndFormat( s.getTime(), s.getFormat() ) )}.
+ *
+ * Any types referenced in expressions must be given via their fully-qualified name. Alternatively, types can be
+ * imported via {@link Mapper#imports()}.
+ *
+ * Either this attribute, {@link #source()} or {@link #constant()} may be specified for a given mapping.
+ *
+ * @return An expression specifying the value for the designated target property
*/
String expression() default "";
+ * {@code @Mapping(
+ * target = "someProp",
+ * expression = "java(new TimeAndFormat( s.getTime(), s.getFormat() ))"
+ * )}
+ *
+ *
+ * {@code @Mapping(
+ * target = "someProp",
+ * expression = "java(new TimeAndFormat( s.getTime(), s.getFormat() ))"
+ * )}
+ *
+ *