1
2
3
4
5 package org.apache.maven.api.model;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import org.apache.maven.api.annotations.Experimental;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Immutable;
17 import org.apache.maven.api.annotations.Nonnull;
18 import org.apache.maven.api.annotations.NotThreadSafe;
19 import org.apache.maven.api.annotations.ThreadSafe;
20
21
22
23
24 @Experimental
25 @Generated @ThreadSafe @Immutable
26 public class Developer
27 extends Contributor
28 implements Serializable, InputLocationTracker
29 {
30
31
32
33 final String id;
34
35
36
37
38
39 Developer(
40 String name,
41 String email,
42 String url,
43 String organization,
44 String organizationUrl,
45 Collection<String> roles,
46 String timezone,
47 Map<String, String> properties,
48 String id,
49 Map<Object, InputLocation> locations
50 ) {
51 super(
52 name,
53 email,
54 url,
55 organization,
56 organizationUrl,
57 roles,
58 timezone,
59 properties,
60 locations
61 );
62 this.id = id;
63 }
64
65
66
67
68
69
70 public String getId() {
71 return this.id;
72 }
73
74
75
76
77
78
79 @Nonnull
80 public Builder with() {
81 return newBuilder(this);
82 }
83
84
85
86
87
88
89 @Nonnull
90 public Developer withName(String name) {
91 return newBuilder(this, true).name(name).build();
92 }
93
94
95
96
97
98
99 @Nonnull
100 public Developer withEmail(String email) {
101 return newBuilder(this, true).email(email).build();
102 }
103
104
105
106
107
108
109 @Nonnull
110 public Developer withUrl(String url) {
111 return newBuilder(this, true).url(url).build();
112 }
113
114
115
116
117
118
119 @Nonnull
120 public Developer withOrganization(String organization) {
121 return newBuilder(this, true).organization(organization).build();
122 }
123
124
125
126
127
128
129 @Nonnull
130 public Developer withOrganizationUrl(String organizationUrl) {
131 return newBuilder(this, true).organizationUrl(organizationUrl).build();
132 }
133
134
135
136
137
138
139 @Nonnull
140 public Developer withRoles(Collection<String> roles) {
141 return newBuilder(this, true).roles(roles).build();
142 }
143
144
145
146
147
148
149 @Nonnull
150 public Developer withTimezone(String timezone) {
151 return newBuilder(this, true).timezone(timezone).build();
152 }
153
154
155
156
157
158
159 @Nonnull
160 public Developer withProperties(Map<String, String> properties) {
161 return newBuilder(this, true).properties(properties).build();
162 }
163
164
165
166
167
168
169 @Nonnull
170 public Developer withId(String id) {
171 return newBuilder(this, true).id(id).build();
172 }
173
174
175
176
177
178
179
180
181 @Nonnull
182 public static Developer newInstance() {
183 return newInstance(true);
184 }
185
186
187
188
189
190
191
192
193 @Nonnull
194 public static Developer newInstance(boolean withDefaults) {
195 return newBuilder(withDefaults).build();
196 }
197
198
199
200
201
202
203
204
205 @Nonnull
206 public static Builder newBuilder() {
207 return newBuilder(true);
208 }
209
210
211
212
213
214
215
216 @Nonnull
217 public static Builder newBuilder(boolean withDefaults) {
218 return new Builder(withDefaults);
219 }
220
221
222
223
224
225
226
227
228 @Nonnull
229 public static Builder newBuilder(Developer from) {
230 return newBuilder(from, false);
231 }
232
233
234
235
236
237
238
239
240 @Nonnull
241 public static Builder newBuilder(Developer from, boolean forceCopy) {
242 return new Builder(from, forceCopy);
243 }
244
245
246
247
248
249
250 @NotThreadSafe
251 public static class Builder
252 extends Contributor.Builder
253 {
254 Developer base;
255 String id;
256
257 Builder(boolean withDefaults) {
258 super(withDefaults);
259 if (withDefaults) {
260 }
261 }
262
263 Builder(Developer base, boolean forceCopy) {
264 super(base, forceCopy);
265 if (forceCopy) {
266 this.id = base.id;
267 this.locations = base.locations;
268 } else {
269 this.base = base;
270 }
271 }
272
273 @Nonnull
274 public Builder name(String name) {
275 this.name = name;
276 return this;
277 }
278
279 @Nonnull
280 public Builder email(String email) {
281 this.email = email;
282 return this;
283 }
284
285 @Nonnull
286 public Builder url(String url) {
287 this.url = url;
288 return this;
289 }
290
291 @Nonnull
292 public Builder organization(String organization) {
293 this.organization = organization;
294 return this;
295 }
296
297 @Nonnull
298 public Builder organizationUrl(String organizationUrl) {
299 this.organizationUrl = organizationUrl;
300 return this;
301 }
302
303 @Nonnull
304 public Builder roles(Collection<String> roles) {
305 this.roles = roles;
306 return this;
307 }
308
309 @Nonnull
310 public Builder timezone(String timezone) {
311 this.timezone = timezone;
312 return this;
313 }
314
315 @Nonnull
316 public Builder properties(Map<String, String> properties) {
317 this.properties = properties;
318 return this;
319 }
320
321 @Nonnull
322 public Builder id(String id) {
323 this.id = id;
324 return this;
325 }
326
327
328 @Nonnull
329 public Builder location(Object key, InputLocation location) {
330 if (location != null) {
331 if (!(this.locations instanceof HashMap)) {
332 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
333 }
334 this.locations.put(key, location);
335 }
336 return this;
337 }
338
339 @Nonnull
340 public Developer build() {
341 if (base != null
342 && (name == null || name == base.name)
343 && (email == null || email == base.email)
344 && (url == null || url == base.url)
345 && (organization == null || organization == base.organization)
346 && (organizationUrl == null || organizationUrl == base.organizationUrl)
347 && (roles == null || roles == base.roles)
348 && (timezone == null || timezone == base.timezone)
349 && (properties == null || properties == base.properties)
350 && (id == null || id == base.id)
351 ) {
352 return base;
353 }
354 Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
355 Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
356 Map<Object, InputLocation> locations = new HashMap<>();
357 locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
358 locations.put("name", newlocs.containsKey("name") ? newlocs.get("name") : oldlocs.get("name"));
359 locations.put("email", newlocs.containsKey("email") ? newlocs.get("email") : oldlocs.get("email"));
360 locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
361 locations.put("organization", newlocs.containsKey("organization") ? newlocs.get("organization") : oldlocs.get("organization"));
362 locations.put("organizationUrl", newlocs.containsKey("organizationUrl") ? newlocs.get("organizationUrl") : oldlocs.get("organizationUrl"));
363 locations.put("roles", newlocs.containsKey("roles") ? newlocs.get("roles") : oldlocs.get("roles"));
364 locations.put("timezone", newlocs.containsKey("timezone") ? newlocs.get("timezone") : oldlocs.get("timezone"));
365 locations.put("properties", newlocs.containsKey("properties") ? newlocs.get("properties") : oldlocs.get("properties"));
366 locations.put("id", newlocs.containsKey("id") ? newlocs.get("id") : oldlocs.get("id"));
367 return new Developer(
368 name != null ? name : (base != null ? base.name : null),
369 email != null ? email : (base != null ? base.email : null),
370 url != null ? url : (base != null ? base.url : null),
371 organization != null ? organization : (base != null ? base.organization : null),
372 organizationUrl != null ? organizationUrl : (base != null ? base.organizationUrl : null),
373 roles != null ? roles : (base != null ? base.roles : null),
374 timezone != null ? timezone : (base != null ? base.timezone : null),
375 properties != null ? properties : (base != null ? base.properties : null),
376 id != null ? id : (base != null ? base.id : null),
377 locations
378 );
379 }
380 }
381
382
383
384
385
386
387 public String toString()
388 {
389 return "Developer {id=" + getId() + ", " + super.toString() + "}";
390 }
391
392
393 }