Skip to content

Commit fc1eee0

Browse files
committed
mapstruct#65 Adding note on nested properties to docs of @mapping#source()
1 parent 1d35f2f commit fc1eee0

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

core-jdk8/src/main/java/org/mapstruct/Mapping.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@
4545
public @interface Mapping {
4646

4747
/**
48-
* The target name of the configured property as defined by the JavaBeans specification. If used to map an enum
49-
* constant, the name of the constant member is to be given.
48+
* The target name of the configured property as defined by the JavaBeans specification. The same target property
49+
* must not be mapped more than once.
50+
* <p>
51+
* If used to map an enum constant, the name of the constant member is to be given. In this case, several values
52+
* from the source enum may be mapped to the same value of the target enum.
5053
*
5154
* @return The target name of the configured property or enum constant
5255
*/
@@ -55,7 +58,11 @@
5558
/**
5659
* The source to use for this mapping. This can either be:
5760
* <ol>
58-
* <li>The source name of the configured property as defined by the JavaBeans specification.</li>
61+
* <li>The source name of the configured property as defined by the JavaBeans specification.
62+
* <p>
63+
* This may either be a simple property name (e.g. "address") or a dot-separated property path (e.g. "address.city"
64+
* or "address.city.name"). In case the annotated method has several source parameters, the property name must
65+
* qualified with the parameter name, e.g. "addressParam.city".</li>
5966
* <li>When used to map an enum constant, the name of the constant member is to be given.</li>
6067
* </ol>
6168
* Either this attribute or {@link #constant()} or {@link #expression()} may be specified for a given mapping.

core/src/main/java/org/mapstruct/Mapping.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
public @interface Mapping {
4444

4545
/**
46-
* The target name of the configured property as defined by the JavaBeans specification. If used to map an enum
47-
* constant, the name of the constant member is to be given.
46+
* The target name of the configured property as defined by the JavaBeans specification. The same target property
47+
* must not be mapped more than once.
48+
* <p>
49+
* If used to map an enum constant, the name of the constant member is to be given. In this case, several values
50+
* from the source enum may be mapped to the same value of the target enum.
4851
*
4952
* @return The target name of the configured property or enum constant
5053
*/
@@ -53,7 +56,11 @@
5356
/**
5457
* The source to use for this mapping. This can either be:
5558
* <ol>
56-
* <li>The source name of the configured property as defined by the JavaBeans specification.</li>
59+
* <li>The source name of the configured property as defined by the JavaBeans specification.
60+
* <p>
61+
* This may either be a simple property name (e.g. "address") or a dot-separated property path (e.g. "address.city"
62+
* or "address.city.name"). In case the annotated method has several source parameters, the property name must
63+
* qualified with the parameter name, e.g. "addressParam.city".</li>
5764
* <li>When used to map an enum constant, the name of the constant member is to be given.</li>
5865
* </ol>
5966
* Either this attribute or {@link #constant()} or {@link #expression()} may be specified for a given mapping.

0 commit comments

Comments
 (0)