1
2
3
4
5 package org.apache.maven.api.plugin.descriptor;
6
7 import java.io.Serializable;
8 import java.util.Collections;
9 import java.util.HashMap;
10 import java.util.Map;
11 import java.util.Set;
12 import org.apache.maven.api.annotations.Experimental;
13 import org.apache.maven.api.annotations.Generated;
14 import org.apache.maven.api.annotations.Immutable;
15 import org.apache.maven.api.annotations.Nonnull;
16 import org.apache.maven.api.annotations.NotThreadSafe;
17 import org.apache.maven.api.annotations.ThreadSafe;
18
19
20
21
22 @Experimental
23 @Generated @ThreadSafe @Immutable
24 public class Requirement
25 implements Serializable
26 {
27
28
29
30 final String role;
31
32
33
34 final String roleHint;
35
36
37
38 final String fieldName;
39
40
41
42
43
44 protected Requirement(Builder builder) {
45 this.role = builder.role != null ? builder.role : (builder.base != null ? builder.base.role : null);
46 this.roleHint = builder.roleHint != null ? builder.roleHint : (builder.base != null ? builder.base.roleHint : null);
47 this.fieldName = builder.fieldName != null ? builder.fieldName : (builder.base != null ? builder.base.fieldName : null);
48 }
49
50
51
52
53
54
55 public String getRole() {
56 return this.role;
57 }
58
59
60
61
62
63
64 public String getRoleHint() {
65 return this.roleHint;
66 }
67
68
69
70
71
72
73 public String getFieldName() {
74 return this.fieldName;
75 }
76
77
78
79
80
81
82 @Nonnull
83 public Builder with() {
84 return newBuilder(this);
85 }
86
87
88
89
90
91
92 @Nonnull
93 public Requirement withRole(String role) {
94 return newBuilder(this, true).role(role).build();
95 }
96
97
98
99
100
101
102 @Nonnull
103 public Requirement withRoleHint(String roleHint) {
104 return newBuilder(this, true).roleHint(roleHint).build();
105 }
106
107
108
109
110
111
112 @Nonnull
113 public Requirement withFieldName(String fieldName) {
114 return newBuilder(this, true).fieldName(fieldName).build();
115 }
116
117
118
119
120
121
122
123
124 @Nonnull
125 public static Requirement newInstance() {
126 return newInstance(true);
127 }
128
129
130
131
132
133
134
135
136 @Nonnull
137 public static Requirement newInstance(boolean withDefaults) {
138 return newBuilder(withDefaults).build();
139 }
140
141
142
143
144
145
146
147
148 @Nonnull
149 public static Builder newBuilder() {
150 return newBuilder(true);
151 }
152
153
154
155
156
157
158
159 @Nonnull
160 public static Builder newBuilder(boolean withDefaults) {
161 return new Builder(withDefaults);
162 }
163
164
165
166
167
168
169
170
171 @Nonnull
172 public static Builder newBuilder(Requirement from) {
173 return newBuilder(from, false);
174 }
175
176
177
178
179
180
181
182
183 @Nonnull
184 public static Builder newBuilder(Requirement from, boolean forceCopy) {
185 return new Builder(from, forceCopy);
186 }
187
188
189
190
191
192
193 @NotThreadSafe
194 public static class Builder
195 {
196 Requirement base;
197 String role;
198 String roleHint;
199 String fieldName;
200
201 protected Builder(boolean withDefaults) {
202 if (withDefaults) {
203 }
204 }
205
206 protected Builder(Requirement base, boolean forceCopy) {
207 if (forceCopy) {
208 this.role = base.role;
209 this.roleHint = base.roleHint;
210 this.fieldName = base.fieldName;
211 } else {
212 this.base = base;
213 }
214 }
215
216 @Nonnull
217 public Builder role(String role) {
218 this.role = role;
219 return this;
220 }
221
222 @Nonnull
223 public Builder roleHint(String roleHint) {
224 this.roleHint = roleHint;
225 return this;
226 }
227
228 @Nonnull
229 public Builder fieldName(String fieldName) {
230 this.fieldName = fieldName;
231 return this;
232 }
233
234
235 @Nonnull
236 public Requirement build() {
237
238 if (base != null
239 && (role == null || role == base.role)
240 && (roleHint == null || roleHint == base.roleHint)
241 && (fieldName == null || fieldName == base.fieldName)
242 ) {
243 return base;
244 }
245 return new Requirement(this);
246 }
247 }
248
249 }