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 Scm
25 implements Serializable, InputLocationTracker
26 {
27
28
29
30
31
32
33
34
35
36
37 final String connection;
38
39
40
41
42
43
44 final String developerConnection;
45
46
47
48 final String tag;
49
50
51
52
53
54 final String url;
55
56
57
58
59
60
61
62 final String childScmConnectionInheritAppendPath;
63
64
65
66
67
68
69
70 final String childScmDeveloperConnectionInheritAppendPath;
71
72
73
74
75
76
77
78 final String childScmUrlInheritAppendPath;
79
80 final Map<Object, InputLocation> locations;
81
82
83
84
85
86 Scm(
87 String connection,
88 String developerConnection,
89 String tag,
90 String url,
91 String childScmConnectionInheritAppendPath,
92 String childScmDeveloperConnectionInheritAppendPath,
93 String childScmUrlInheritAppendPath,
94 Map<Object, InputLocation> locations
95 ) {
96 this.connection = connection;
97 this.developerConnection = developerConnection;
98 this.tag = tag;
99 this.url = url;
100 this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
101 this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
102 this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
103 this.locations = ImmutableCollections.copy(locations);
104 }
105
106
107
108
109
110
111
112
113
114
115
116
117
118 public String getConnection() {
119 return this.connection;
120 }
121
122
123
124
125
126
127
128
129
130 public String getDeveloperConnection() {
131 return this.developerConnection;
132 }
133
134
135
136
137
138
139 public String getTag() {
140 return this.tag;
141 }
142
143
144
145
146
147
148
149
150 public String getUrl() {
151 return this.url;
152 }
153
154
155
156
157
158
159
160
161
162
163 public String getChildScmConnectionInheritAppendPath() {
164 return this.childScmConnectionInheritAppendPath;
165 }
166
167
168
169
170
171
172
173
174
175
176 public String getChildScmDeveloperConnectionInheritAppendPath() {
177 return this.childScmDeveloperConnectionInheritAppendPath;
178 }
179
180
181
182
183
184
185
186
187
188
189 public String getChildScmUrlInheritAppendPath() {
190 return this.childScmUrlInheritAppendPath;
191 }
192
193
194
195
196 public InputLocation getLocation(Object key) {
197 return locations != null ? locations.get(key) : null;
198 }
199
200
201
202
203
204
205 @Nonnull
206 public Builder with() {
207 return newBuilder(this);
208 }
209
210
211
212
213
214
215 @Nonnull
216 public Scm withConnection(String connection) {
217 return newBuilder(this, true).connection(connection).build();
218 }
219
220
221
222
223
224
225 @Nonnull
226 public Scm withDeveloperConnection(String developerConnection) {
227 return newBuilder(this, true).developerConnection(developerConnection).build();
228 }
229
230
231
232
233
234
235 @Nonnull
236 public Scm withTag(String tag) {
237 return newBuilder(this, true).tag(tag).build();
238 }
239
240
241
242
243
244
245 @Nonnull
246 public Scm withUrl(String url) {
247 return newBuilder(this, true).url(url).build();
248 }
249
250
251
252
253
254
255 @Nonnull
256 public Scm withChildScmConnectionInheritAppendPath(String childScmConnectionInheritAppendPath) {
257 return newBuilder(this, true).childScmConnectionInheritAppendPath(childScmConnectionInheritAppendPath).build();
258 }
259
260
261
262
263
264
265 @Nonnull
266 public Scm withChildScmDeveloperConnectionInheritAppendPath(String childScmDeveloperConnectionInheritAppendPath) {
267 return newBuilder(this, true).childScmDeveloperConnectionInheritAppendPath(childScmDeveloperConnectionInheritAppendPath).build();
268 }
269
270
271
272
273
274
275 @Nonnull
276 public Scm withChildScmUrlInheritAppendPath(String childScmUrlInheritAppendPath) {
277 return newBuilder(this, true).childScmUrlInheritAppendPath(childScmUrlInheritAppendPath).build();
278 }
279
280
281
282
283
284
285
286
287 @Nonnull
288 public static Scm newInstance() {
289 return newInstance(true);
290 }
291
292
293
294
295
296
297
298
299 @Nonnull
300 public static Scm newInstance(boolean withDefaults) {
301 return newBuilder(withDefaults).build();
302 }
303
304
305
306
307
308
309
310
311 @Nonnull
312 public static Builder newBuilder() {
313 return newBuilder(true);
314 }
315
316
317
318
319
320
321
322 @Nonnull
323 public static Builder newBuilder(boolean withDefaults) {
324 return new Builder(withDefaults);
325 }
326
327
328
329
330
331
332
333
334 @Nonnull
335 public static Builder newBuilder(Scm from) {
336 return newBuilder(from, false);
337 }
338
339
340
341
342
343
344
345
346 @Nonnull
347 public static Builder newBuilder(Scm from, boolean forceCopy) {
348 return new Builder(from, forceCopy);
349 }
350
351
352
353
354
355
356 @NotThreadSafe
357 public static class Builder
358 {
359 Scm base;
360 String connection;
361 String developerConnection;
362 String tag;
363 String url;
364 String childScmConnectionInheritAppendPath;
365 String childScmDeveloperConnectionInheritAppendPath;
366 String childScmUrlInheritAppendPath;
367 Map<Object, InputLocation> locations;
368
369 Builder(boolean withDefaults) {
370 if (withDefaults) {
371 this.tag = "HEAD";
372 }
373 }
374
375 Builder(Scm base, boolean forceCopy) {
376 if (forceCopy) {
377 this.connection = base.connection;
378 this.developerConnection = base.developerConnection;
379 this.tag = base.tag;
380 this.url = base.url;
381 this.childScmConnectionInheritAppendPath = base.childScmConnectionInheritAppendPath;
382 this.childScmDeveloperConnectionInheritAppendPath = base.childScmDeveloperConnectionInheritAppendPath;
383 this.childScmUrlInheritAppendPath = base.childScmUrlInheritAppendPath;
384 this.locations = base.locations;
385 } else {
386 this.base = base;
387 }
388 }
389
390 @Nonnull
391 public Builder connection(String connection) {
392 this.connection = connection;
393 return this;
394 }
395
396 @Nonnull
397 public Builder developerConnection(String developerConnection) {
398 this.developerConnection = developerConnection;
399 return this;
400 }
401
402 @Nonnull
403 public Builder tag(String tag) {
404 this.tag = tag;
405 return this;
406 }
407
408 @Nonnull
409 public Builder url(String url) {
410 this.url = url;
411 return this;
412 }
413
414 @Nonnull
415 public Builder childScmConnectionInheritAppendPath(String childScmConnectionInheritAppendPath) {
416 this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
417 return this;
418 }
419
420 @Nonnull
421 public Builder childScmDeveloperConnectionInheritAppendPath(String childScmDeveloperConnectionInheritAppendPath) {
422 this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
423 return this;
424 }
425
426 @Nonnull
427 public Builder childScmUrlInheritAppendPath(String childScmUrlInheritAppendPath) {
428 this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
429 return this;
430 }
431
432
433 @Nonnull
434 public Builder location(Object key, InputLocation location) {
435 if (location != null) {
436 if (!(this.locations instanceof HashMap)) {
437 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
438 }
439 this.locations.put(key, location);
440 }
441 return this;
442 }
443
444 @Nonnull
445 public Scm build() {
446 if (base != null
447 && (connection == null || connection == base.connection)
448 && (developerConnection == null || developerConnection == base.developerConnection)
449 && (tag == null || tag == base.tag)
450 && (url == null || url == base.url)
451 && (childScmConnectionInheritAppendPath == null || childScmConnectionInheritAppendPath == base.childScmConnectionInheritAppendPath)
452 && (childScmDeveloperConnectionInheritAppendPath == null || childScmDeveloperConnectionInheritAppendPath == base.childScmDeveloperConnectionInheritAppendPath)
453 && (childScmUrlInheritAppendPath == null || childScmUrlInheritAppendPath == base.childScmUrlInheritAppendPath)
454 ) {
455 return base;
456 }
457 Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
458 Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
459 Map<Object, InputLocation> locations = new HashMap<>();
460 locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
461 locations.put("connection", newlocs.containsKey("connection") ? newlocs.get("connection") : oldlocs.get("connection"));
462 locations.put("developerConnection", newlocs.containsKey("developerConnection") ? newlocs.get("developerConnection") : oldlocs.get("developerConnection"));
463 locations.put("tag", newlocs.containsKey("tag") ? newlocs.get("tag") : oldlocs.get("tag"));
464 locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
465 locations.put("childScmConnectionInheritAppendPath", newlocs.containsKey("childScmConnectionInheritAppendPath") ? newlocs.get("childScmConnectionInheritAppendPath") : oldlocs.get("childScmConnectionInheritAppendPath"));
466 locations.put("childScmDeveloperConnectionInheritAppendPath", newlocs.containsKey("childScmDeveloperConnectionInheritAppendPath") ? newlocs.get("childScmDeveloperConnectionInheritAppendPath") : oldlocs.get("childScmDeveloperConnectionInheritAppendPath"));
467 locations.put("childScmUrlInheritAppendPath", newlocs.containsKey("childScmUrlInheritAppendPath") ? newlocs.get("childScmUrlInheritAppendPath") : oldlocs.get("childScmUrlInheritAppendPath"));
468 return new Scm(
469 connection != null ? connection : (base != null ? base.connection : null),
470 developerConnection != null ? developerConnection : (base != null ? base.developerConnection : null),
471 tag != null ? tag : (base != null ? base.tag : null),
472 url != null ? url : (base != null ? base.url : null),
473 childScmConnectionInheritAppendPath != null ? childScmConnectionInheritAppendPath : (base != null ? base.childScmConnectionInheritAppendPath : null),
474 childScmDeveloperConnectionInheritAppendPath != null ? childScmDeveloperConnectionInheritAppendPath : (base != null ? base.childScmDeveloperConnectionInheritAppendPath : null),
475 childScmUrlInheritAppendPath != null ? childScmUrlInheritAppendPath : (base != null ? base.childScmUrlInheritAppendPath : null),
476 locations
477 );
478 }
479 }
480
481
482
483
484 public boolean isChildScmConnectionInheritAppendPath()
485 {
486 return ( getChildScmConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmConnectionInheritAppendPath() ) : true;
487 }
488
489 public boolean isChildScmDeveloperConnectionInheritAppendPath()
490 {
491 return ( getChildScmDeveloperConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmDeveloperConnectionInheritAppendPath() ) : true;
492 }
493
494 public boolean isChildScmUrlInheritAppendPath()
495 {
496 return ( getChildScmUrlInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmUrlInheritAppendPath() ) : true;
497 }
498
499
500
501
502
503
504
505
506 public String toString()
507 {
508 return "Scm {connection=" + getConnection() + "}";
509 }
510
511
512 }