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 InputLocation location;
81
82 final InputLocation connectionLocation;
83
84 final InputLocation developerConnectionLocation;
85
86 final InputLocation tagLocation;
87
88 final InputLocation urlLocation;
89
90 final InputLocation childScmConnectionInheritAppendPathLocation;
91
92 final InputLocation childScmDeveloperConnectionInheritAppendPathLocation;
93
94 final InputLocation childScmUrlInheritAppendPathLocation;
95
96 final Map<Object, InputLocation> locations;
97
98
99
100
101
102 Scm(
103 String connection,
104 String developerConnection,
105 String tag,
106 String url,
107 String childScmConnectionInheritAppendPath,
108 String childScmDeveloperConnectionInheritAppendPath,
109 String childScmUrlInheritAppendPath,
110 Map<Object, InputLocation> locations,
111 InputLocation location,
112 InputLocation connectionLocation,
113 InputLocation developerConnectionLocation,
114 InputLocation tagLocation,
115 InputLocation urlLocation,
116 InputLocation childScmConnectionInheritAppendPathLocation,
117 InputLocation childScmDeveloperConnectionInheritAppendPathLocation,
118 InputLocation childScmUrlInheritAppendPathLocation
119 )
120 {
121 this.connection = connection;
122 this.developerConnection = developerConnection;
123 this.tag = tag;
124 this.url = url;
125 this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
126 this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
127 this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
128 this.locations = ImmutableCollections.copy( locations );
129 this.location = location;
130 this.connectionLocation = connectionLocation;
131 this.developerConnectionLocation = developerConnectionLocation;
132 this.tagLocation = tagLocation;
133 this.urlLocation = urlLocation;
134 this.childScmConnectionInheritAppendPathLocation = childScmConnectionInheritAppendPathLocation;
135 this.childScmDeveloperConnectionInheritAppendPathLocation = childScmDeveloperConnectionInheritAppendPathLocation;
136 this.childScmUrlInheritAppendPathLocation = childScmUrlInheritAppendPathLocation;
137 }
138
139
140
141
142
143
144
145
146
147
148
149
150
151 public String getConnection()
152 {
153 return this.connection;
154 }
155
156
157
158
159
160
161
162
163
164 public String getDeveloperConnection()
165 {
166 return this.developerConnection;
167 }
168
169
170
171
172
173
174 public String getTag()
175 {
176 return this.tag;
177 }
178
179
180
181
182
183
184
185
186 public String getUrl()
187 {
188 return this.url;
189 }
190
191
192
193
194
195
196
197
198
199
200 public String getChildScmConnectionInheritAppendPath()
201 {
202 return this.childScmConnectionInheritAppendPath;
203 }
204
205
206
207
208
209
210
211
212
213
214 public String getChildScmDeveloperConnectionInheritAppendPath()
215 {
216 return this.childScmDeveloperConnectionInheritAppendPath;
217 }
218
219
220
221
222
223
224
225
226
227
228 public String getChildScmUrlInheritAppendPath()
229 {
230 return this.childScmUrlInheritAppendPath;
231 }
232
233
234
235
236 public InputLocation getLocation( Object key )
237 {
238 if ( key instanceof String )
239 {
240 switch ( ( String ) key )
241 {
242 case "":
243 return location;
244 case "connection":
245 return connectionLocation;
246 case "developerConnection":
247 return developerConnectionLocation;
248 case "tag":
249 return tagLocation;
250 case "url":
251 return urlLocation;
252 case "childScmConnectionInheritAppendPath":
253 return childScmConnectionInheritAppendPathLocation;
254 case "childScmDeveloperConnectionInheritAppendPath":
255 return childScmDeveloperConnectionInheritAppendPathLocation;
256 case "childScmUrlInheritAppendPath":
257 return childScmUrlInheritAppendPathLocation;
258 }
259 }
260 return locations != null ? locations.get( key ) : null;
261 }
262
263
264
265
266
267
268 @Nonnull
269 public Builder with()
270 {
271 return newBuilder( this );
272 }
273
274
275
276
277
278
279 @Nonnull
280 public Scm withConnection( String connection )
281 {
282 return with().connection( connection ).build();
283 }
284
285
286
287
288
289
290 @Nonnull
291 public Scm withDeveloperConnection( String developerConnection )
292 {
293 return with().developerConnection( developerConnection ).build();
294 }
295
296
297
298
299
300
301 @Nonnull
302 public Scm withTag( String tag )
303 {
304 return with().tag( tag ).build();
305 }
306
307
308
309
310
311
312 @Nonnull
313 public Scm withUrl( String url )
314 {
315 return with().url( url ).build();
316 }
317
318
319
320
321
322
323 @Nonnull
324 public Scm withChildScmConnectionInheritAppendPath( String childScmConnectionInheritAppendPath )
325 {
326 return with().childScmConnectionInheritAppendPath( childScmConnectionInheritAppendPath ).build();
327 }
328
329
330
331
332
333
334 @Nonnull
335 public Scm withChildScmDeveloperConnectionInheritAppendPath( String childScmDeveloperConnectionInheritAppendPath )
336 {
337 return with().childScmDeveloperConnectionInheritAppendPath( childScmDeveloperConnectionInheritAppendPath ).build();
338 }
339
340
341
342
343
344
345 @Nonnull
346 public Scm withChildScmUrlInheritAppendPath( String childScmUrlInheritAppendPath )
347 {
348 return with().childScmUrlInheritAppendPath( childScmUrlInheritAppendPath ).build();
349 }
350
351
352
353
354
355
356
357
358 @Nonnull
359 public static Scm newInstance()
360 {
361 return newInstance( true );
362 }
363
364
365
366
367
368
369
370
371 @Nonnull
372 public static Scm newInstance( boolean withDefaults )
373 {
374 return newBuilder( withDefaults ).build();
375 }
376
377
378
379
380
381
382
383
384 @Nonnull
385 public static Builder newBuilder()
386 {
387 return newBuilder( true );
388 }
389
390
391
392
393
394
395
396 @Nonnull
397 public static Builder newBuilder( boolean withDefaults )
398 {
399 return new Builder( withDefaults );
400 }
401
402
403
404
405
406
407
408
409 @Nonnull
410 public static Builder newBuilder( Scm from )
411 {
412 return newBuilder( from, false );
413 }
414
415
416
417
418
419
420
421
422 @Nonnull
423 public static Builder newBuilder( Scm from, boolean forceCopy )
424 {
425 return new Builder( from, forceCopy );
426 }
427
428
429
430
431
432
433 @NotThreadSafe
434 public static class Builder
435 {
436 Scm base;
437 String connection;
438 String developerConnection;
439 String tag;
440 String url;
441 String childScmConnectionInheritAppendPath;
442 String childScmDeveloperConnectionInheritAppendPath;
443 String childScmUrlInheritAppendPath;
444 Map<Object, InputLocation> locations;
445
446 Builder( boolean withDefaults )
447 {
448 if ( withDefaults )
449 {
450 this.tag = "HEAD";
451 }
452 }
453
454 Builder( Scm base, boolean forceCopy )
455 {
456 if ( forceCopy )
457 {
458 this.connection = base.connection;
459 this.developerConnection = base.developerConnection;
460 this.tag = base.tag;
461 this.url = base.url;
462 this.childScmConnectionInheritAppendPath = base.childScmConnectionInheritAppendPath;
463 this.childScmDeveloperConnectionInheritAppendPath = base.childScmDeveloperConnectionInheritAppendPath;
464 this.childScmUrlInheritAppendPath = base.childScmUrlInheritAppendPath;
465 }
466 else
467 {
468 this.base = base;
469 }
470 }
471
472 @Nonnull
473 public Builder connection( String connection )
474 {
475 this.connection = connection;
476 return this;
477 }
478
479 @Nonnull
480 public Builder developerConnection( String developerConnection )
481 {
482 this.developerConnection = developerConnection;
483 return this;
484 }
485
486 @Nonnull
487 public Builder tag( String tag )
488 {
489 this.tag = tag;
490 return this;
491 }
492
493 @Nonnull
494 public Builder url( String url )
495 {
496 this.url = url;
497 return this;
498 }
499
500 @Nonnull
501 public Builder childScmConnectionInheritAppendPath( String childScmConnectionInheritAppendPath )
502 {
503 this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
504 return this;
505 }
506
507 @Nonnull
508 public Builder childScmDeveloperConnectionInheritAppendPath( String childScmDeveloperConnectionInheritAppendPath )
509 {
510 this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
511 return this;
512 }
513
514 @Nonnull
515 public Builder childScmUrlInheritAppendPath( String childScmUrlInheritAppendPath )
516 {
517 this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
518 return this;
519 }
520
521
522 @Nonnull
523 public Builder location( Object key, InputLocation location )
524 {
525 if ( location != null )
526 {
527 if ( this.locations == null )
528 {
529 this.locations = new HashMap<>();
530 }
531 this.locations.put( key, location );
532 }
533 return this;
534 }
535
536 @Nonnull
537 public Scm build()
538 {
539 if ( base != null
540 && ( connection == null || connection == base.connection )
541 && ( developerConnection == null || developerConnection == base.developerConnection )
542 && ( tag == null || tag == base.tag )
543 && ( url == null || url == base.url )
544 && ( childScmConnectionInheritAppendPath == null || childScmConnectionInheritAppendPath == base.childScmConnectionInheritAppendPath )
545 && ( childScmDeveloperConnectionInheritAppendPath == null || childScmDeveloperConnectionInheritAppendPath == base.childScmDeveloperConnectionInheritAppendPath )
546 && ( childScmUrlInheritAppendPath == null || childScmUrlInheritAppendPath == base.childScmUrlInheritAppendPath )
547 )
548 {
549 return base;
550 }
551 Map<Object, InputLocation> locations = null;
552 InputLocation location = null;
553 InputLocation connectionLocation = null;
554 InputLocation developerConnectionLocation = null;
555 InputLocation tagLocation = null;
556 InputLocation urlLocation = null;
557 InputLocation childScmConnectionInheritAppendPathLocation = null;
558 InputLocation childScmDeveloperConnectionInheritAppendPathLocation = null;
559 InputLocation childScmUrlInheritAppendPathLocation = null;
560 if ( this.locations != null )
561 {
562 locations = this.locations;
563 location = locations.remove( "" );
564 connectionLocation = locations.remove( "connection" );
565 developerConnectionLocation = locations.remove( "developerConnection" );
566 tagLocation = locations.remove( "tag" );
567 urlLocation = locations.remove( "url" );
568 childScmConnectionInheritAppendPathLocation = locations.remove( "childScmConnectionInheritAppendPath" );
569 childScmDeveloperConnectionInheritAppendPathLocation = locations.remove( "childScmDeveloperConnectionInheritAppendPath" );
570 childScmUrlInheritAppendPathLocation = locations.remove( "childScmUrlInheritAppendPath" );
571 }
572 return new Scm(
573 connection != null ? connection : ( base != null ? base.connection : null ),
574 developerConnection != null ? developerConnection : ( base != null ? base.developerConnection : null ),
575 tag != null ? tag : ( base != null ? base.tag : null ),
576 url != null ? url : ( base != null ? base.url : null ),
577 childScmConnectionInheritAppendPath != null ? childScmConnectionInheritAppendPath : ( base != null ? base.childScmConnectionInheritAppendPath : null ),
578 childScmDeveloperConnectionInheritAppendPath != null ? childScmDeveloperConnectionInheritAppendPath : ( base != null ? base.childScmDeveloperConnectionInheritAppendPath : null ),
579 childScmUrlInheritAppendPath != null ? childScmUrlInheritAppendPath : ( base != null ? base.childScmUrlInheritAppendPath : null ),
580 locations != null ? locations : ( base != null ? base.locations : null ),
581 location != null ? location : ( base != null ? base.location : null ),
582 connectionLocation != null ? connectionLocation : ( base != null ? base.connectionLocation : null ),
583 developerConnectionLocation != null ? developerConnectionLocation : ( base != null ? base.developerConnectionLocation : null ),
584 tagLocation != null ? tagLocation : ( base != null ? base.tagLocation : null ),
585 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null ),
586 childScmConnectionInheritAppendPathLocation != null ? childScmConnectionInheritAppendPathLocation : ( base != null ? base.childScmConnectionInheritAppendPathLocation : null ),
587 childScmDeveloperConnectionInheritAppendPathLocation != null ? childScmDeveloperConnectionInheritAppendPathLocation : ( base != null ? base.childScmDeveloperConnectionInheritAppendPathLocation : null ),
588 childScmUrlInheritAppendPathLocation != null ? childScmUrlInheritAppendPathLocation : ( base != null ? base.childScmUrlInheritAppendPathLocation : null )
589 );
590 }
591 }
592
593
594
595
596 public boolean isChildScmConnectionInheritAppendPath()
597 {
598 return ( getChildScmConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmConnectionInheritAppendPath() ) : true;
599 }
600
601 public boolean isChildScmDeveloperConnectionInheritAppendPath()
602 {
603 return ( getChildScmDeveloperConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmDeveloperConnectionInheritAppendPath() ) : true;
604 }
605
606 public boolean isChildScmUrlInheritAppendPath()
607 {
608 return ( getChildScmUrlInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmUrlInheritAppendPath() ) : true;
609 }
610
611
612
613
614
615
616
617
618 public String toString()
619 {
620 return "Scm {connection=" + getConnection() + "}";
621 }
622
623
624 }