forked from mapstruct/mapstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMappingTarget.java
More file actions
62 lines (60 loc) · 1.63 KB
/
MappingTarget.java
File metadata and controls
62 lines (60 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Declares a parameter of a mapping method to be the target of the mapping.
* <p>
* Not more than one parameter can be declared as {@code MappingTarget}.
* <p>
* <b>NOTE:</b> The parameter passed as a mapping target <b>must</b> not be {@code null}.
*
* <p>
* <strong>Example 1:</strong> Update exist bean without return value
* </p>
* <pre><code class='java'>
* @Mapper
* public interface HumanMapper {
* void updateHuman(HumanDto humanDto, @MappingTarget Human human);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* @Override
* public void updateHuman(HumanDto humanDto, Human human) {
* human.setName( humanDto.getName() );
* // ...
* }
* </code></pre>
* <p>
* <strong>Example 2:</strong> Update exist bean and return it
* </p>
* <pre><code class='java'>
* @Mapper
* public interface HumanMapper {
* Human updateHuman(HumanDto humanDto, @MappingTarget Human human);
* }
* </code></pre>
* // generates:
* <pre><code class='java'>
* @Override
* public Human updateHuman(HumanDto humanDto, Human human) {
* // ...
* human.setName( humanDto.getName() );
* return human;
* }
*</code></pre>
*
*
* @author Andreas Gudian
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface MappingTarget {
}