View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model.vm
3   //  template, any modifications will be overwritten.
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   * The {@code <scm>} element contains informations required to the SCM
20   * (Source Control Management) of the project.
21   */
22  @Experimental
23  @Generated @ThreadSafe @Immutable
24  public class Scm
25      implements Serializable, InputLocationTracker
26  {
27      /**
28       * The source control management system URL
29       * that describes the repository and how to connect to the
30       * repository. For more information, see the
31       * <a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
32       * and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
33       * This connection is read-only.
34       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
35       * scm's {@code child.scm.connection.inherit.append.path="false"}
36       */
37      final String connection;
38      /**
39       * Just like {@code connection}, but for developers, i.e. this scm connection
40       * will not be read only.
41       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
42       * scm's {@code child.scm.developerConnection.inherit.append.path="false"}
43       */
44      final String developerConnection;
45      /**
46       * The tag of current code. By default, it's set to HEAD during development.
47       */
48      final String tag;
49      /**
50       * The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
51       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
52       * scm's {@code child.scm.url.inherit.append.path="false"}
53       */
54      final String url;
55      /**
56       * When children inherit from scm connection, append path or not? Note: While the type
57       * of this field is {@code String} for technical reasons, the semantic type is actually
58       * {@code Boolean}
59       * <br><b>Default value is</b>: {@code true}
60       * <br><b>Since</b>: Maven 3.6.1
61       */
62      final String childScmConnectionInheritAppendPath;
63      /**
64       * When children inherit from scm developer connection, append path or not? Note: While the type
65       * of this field is {@code String} for technical reasons, the semantic type is actually
66       * {@code Boolean}
67       * <br><b>Default value is</b>: {@code true}
68       * <br><b>Since</b>: Maven 3.6.1
69       */
70      final String childScmDeveloperConnectionInheritAppendPath;
71      /**
72       * When children inherit from scm url, append path or not? Note: While the type
73       * of this field is {@code String} for technical reasons, the semantic type is actually
74       * {@code Boolean}
75       * <br><b>Default value is</b>: {@code true}
76       * <br><b>Since</b>: Maven 3.6.1
77       */
78      final String childScmUrlInheritAppendPath;
79      /** Locations */
80      final Map<Object, InputLocation> locations;
81  
82      /**
83        * Constructor for this class, package protected.
84        * @see Builder#build()
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      * The source control management system URL
108      * that describes the repository and how to connect to the
109      * repository. For more information, see the
110      * <a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
111      * and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
112      * This connection is read-only.
113      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
114      * scm's {@code child.scm.connection.inherit.append.path="false"}
115      *
116      * @return a {@code String}
117      */
118     public String getConnection() {
119         return this.connection;
120     }
121 
122     /**
123      * Just like {@code connection}, but for developers, i.e. this scm connection
124      * will not be read only.
125      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
126      * scm's {@code child.scm.developerConnection.inherit.append.path="false"}
127      *
128      * @return a {@code String}
129      */
130     public String getDeveloperConnection() {
131         return this.developerConnection;
132     }
133 
134     /**
135      * The tag of current code. By default, it's set to HEAD during development.
136      *
137      * @return a {@code String}
138      */
139     public String getTag() {
140         return this.tag;
141     }
142 
143     /**
144      * The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
145      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
146      * scm's {@code child.scm.url.inherit.append.path="false"}
147      *
148      * @return a {@code String}
149      */
150     public String getUrl() {
151         return this.url;
152     }
153 
154     /**
155      * When children inherit from scm connection, append path or not? Note: While the type
156      * of this field is {@code String} for technical reasons, the semantic type is actually
157      * {@code Boolean}
158      * <br><b>Default value is</b>: {@code true}
159      * <br><b>Since</b>: Maven 3.6.1
160      *
161      * @return a {@code String}
162      */
163     public String getChildScmConnectionInheritAppendPath() {
164         return this.childScmConnectionInheritAppendPath;
165     }
166 
167     /**
168      * When children inherit from scm developer connection, append path or not? Note: While the type
169      * of this field is {@code String} for technical reasons, the semantic type is actually
170      * {@code Boolean}
171      * <br><b>Default value is</b>: {@code true}
172      * <br><b>Since</b>: Maven 3.6.1
173      *
174      * @return a {@code String}
175      */
176     public String getChildScmDeveloperConnectionInheritAppendPath() {
177         return this.childScmDeveloperConnectionInheritAppendPath;
178     }
179 
180     /**
181      * When children inherit from scm url, append path or not? Note: While the type
182      * of this field is {@code String} for technical reasons, the semantic type is actually
183      * {@code Boolean}
184      * <br><b>Default value is</b>: {@code true}
185      * <br><b>Since</b>: Maven 3.6.1
186      *
187      * @return a {@code String}
188      */
189     public String getChildScmUrlInheritAppendPath() {
190         return this.childScmUrlInheritAppendPath;
191     }
192 
193     /**
194      * Gets the location of the specified field in the input source.
195      */
196     public InputLocation getLocation(Object key) {
197         return locations != null ? locations.get(key) : null;
198     }
199 
200     /**
201      * Creates a new builder with this object as the basis.
202      *
203      * @return a {@code Builder}
204      */
205     @Nonnull
206     public Builder with() {
207         return newBuilder(this);
208     }
209     /**
210      * Creates a new {@code Scm} instance using the specified connection.
211      *
212      * @param connection the new {@code String} to use
213      * @return a {@code Scm} with the specified connection
214      */
215     @Nonnull
216     public Scm withConnection(String connection) {
217         return newBuilder(this, true).connection(connection).build();
218     }
219     /**
220      * Creates a new {@code Scm} instance using the specified developerConnection.
221      *
222      * @param developerConnection the new {@code String} to use
223      * @return a {@code Scm} with the specified developerConnection
224      */
225     @Nonnull
226     public Scm withDeveloperConnection(String developerConnection) {
227         return newBuilder(this, true).developerConnection(developerConnection).build();
228     }
229     /**
230      * Creates a new {@code Scm} instance using the specified tag.
231      *
232      * @param tag the new {@code String} to use
233      * @return a {@code Scm} with the specified tag
234      */
235     @Nonnull
236     public Scm withTag(String tag) {
237         return newBuilder(this, true).tag(tag).build();
238     }
239     /**
240      * Creates a new {@code Scm} instance using the specified url.
241      *
242      * @param url the new {@code String} to use
243      * @return a {@code Scm} with the specified url
244      */
245     @Nonnull
246     public Scm withUrl(String url) {
247         return newBuilder(this, true).url(url).build();
248     }
249     /**
250      * Creates a new {@code Scm} instance using the specified childScmConnectionInheritAppendPath.
251      *
252      * @param childScmConnectionInheritAppendPath the new {@code String} to use
253      * @return a {@code Scm} with the specified childScmConnectionInheritAppendPath
254      */
255     @Nonnull
256     public Scm withChildScmConnectionInheritAppendPath(String childScmConnectionInheritAppendPath) {
257         return newBuilder(this, true).childScmConnectionInheritAppendPath(childScmConnectionInheritAppendPath).build();
258     }
259     /**
260      * Creates a new {@code Scm} instance using the specified childScmDeveloperConnectionInheritAppendPath.
261      *
262      * @param childScmDeveloperConnectionInheritAppendPath the new {@code String} to use
263      * @return a {@code Scm} with the specified childScmDeveloperConnectionInheritAppendPath
264      */
265     @Nonnull
266     public Scm withChildScmDeveloperConnectionInheritAppendPath(String childScmDeveloperConnectionInheritAppendPath) {
267         return newBuilder(this, true).childScmDeveloperConnectionInheritAppendPath(childScmDeveloperConnectionInheritAppendPath).build();
268     }
269     /**
270      * Creates a new {@code Scm} instance using the specified childScmUrlInheritAppendPath.
271      *
272      * @param childScmUrlInheritAppendPath the new {@code String} to use
273      * @return a {@code Scm} with the specified childScmUrlInheritAppendPath
274      */
275     @Nonnull
276     public Scm withChildScmUrlInheritAppendPath(String childScmUrlInheritAppendPath) {
277         return newBuilder(this, true).childScmUrlInheritAppendPath(childScmUrlInheritAppendPath).build();
278     }
279 
280     /**
281      * Creates a new {@code Scm} instance.
282      * Equivalent to {@code newInstance(true)}.
283      * @see #newInstance(boolean)
284      *
285      * @return a new {@code Scm}
286      */
287     @Nonnull
288     public static Scm newInstance() {
289         return newInstance(true);
290     }
291 
292     /**
293      * Creates a new {@code Scm} instance using default values or not.
294      * Equivalent to {@code newBuilder(withDefaults).build()}.
295      *
296      * @param withDefaults the boolean indicating whether default values should be used
297      * @return a new {@code Scm}
298      */
299     @Nonnull
300     public static Scm newInstance(boolean withDefaults) {
301         return newBuilder(withDefaults).build();
302     }
303 
304     /**
305      * Creates a new {@code Scm} builder instance.
306      * Equivalent to {@code newBuilder(true)}.
307      * @see #newBuilder(boolean)
308      *
309      * @return a new {@code Builder}
310      */
311     @Nonnull
312     public static Builder newBuilder() {
313         return newBuilder(true);
314     }
315 
316     /**
317      * Creates a new {@code Scm} builder instance using default values or not.
318      *
319      * @param withDefaults the boolean indicating whether default values should be used
320      * @return a new {@code Builder}
321      */
322     @Nonnull
323     public static Builder newBuilder(boolean withDefaults) {
324         return new Builder(withDefaults);
325     }
326 
327     /**
328      * Creates a new {@code Scm} builder instance using the specified object as a basis.
329      * Equivalent to {@code newBuilder(from, false)}.
330      *
331      * @param from the {@code Scm} instance to use as a basis
332      * @return a new {@code Builder}
333      */
334     @Nonnull
335     public static Builder newBuilder(Scm from) {
336         return newBuilder(from, false);
337     }
338 
339     /**
340      * Creates a new {@code Scm} builder instance using the specified object as a basis.
341      *
342      * @param from the {@code Scm} instance to use as a basis
343      * @param forceCopy the boolean indicating if a copy should be forced
344      * @return a new {@code Builder}
345      */
346     @Nonnull
347     public static Builder newBuilder(Scm from, boolean forceCopy) {
348         return new Builder(from, forceCopy);
349     }
350 
351     /**
352      * Builder class used to create Scm instances.
353      * @see #with()
354      * @see #newBuilder()
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      * @see java.lang.Object#toString()
505      */
506     public String toString()
507     {
508         return "Scm {connection=" + getConnection() + "}";
509     }
510             
511           
512 }