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