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