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.nio.file.Path;
9   import java.util.ArrayList;
10  import java.util.Collection;
11  import java.util.Collections;
12  import java.util.HashMap;
13  import java.util.List;
14  import java.util.Map;
15  import java.util.Set;
16  import org.apache.maven.api.annotations.Experimental;
17  import org.apache.maven.api.annotations.Generated;
18  import org.apache.maven.api.annotations.Immutable;
19  import org.apache.maven.api.annotations.Nonnull;
20  import org.apache.maven.api.annotations.NotThreadSafe;
21  import org.apache.maven.api.annotations.ThreadSafe;
22  
23  /**
24   * The {@code <project>} element is the root of the descriptor.
25   * The following table lists all of the possible child elements.
26   */
27  @Experimental
28  @Generated @ThreadSafe @Immutable
29  public class Model
30      extends ModelBase
31      implements Serializable, InputLocationTracker
32  {
33      final String namespaceUri;
34      final String modelEncoding;
35      /**
36       * Originating POM file
37       */
38      final Path pomFile;
39      /**
40       * Declares to which version of project descriptor this POM conforms.
41       */
42      final String modelVersion;
43      /**
44       * The location of the parent project, if one exists. Values from the parent
45       * project will be the default for this project if they are left unspecified. The location
46       * is given as a group ID, artifact ID and version.
47       */
48      final Parent parent;
49      /**
50       * A universally unique identifier for a project. It is normal to
51       * use a fully-qualified package name to distinguish it from other
52       * projects with a similar name (eg. {@code org.apache.maven}).
53       */
54      final String groupId;
55      /**
56       * The identifier for this artifact that is unique within the group given by the
57       * group ID. An artifact is something that is either produced or used by a project.
58       * Examples of artifacts produced by Maven for a project include: JARs, source and binary
59       * distributions, and WARs.
60       */
61      final String artifactId;
62      /**
63       * The current version of the artifact produced by this project.
64       */
65      final String version;
66      /**
67       * The type of artifact this project produces, for example {@code jar},
68       * {@code war},
69       * {@code ear},
70       * {@code pom}.
71       * Plugins can create their own packaging, and
72       * therefore their own packaging types,
73       * so this list does not contain all possible types.
74       */
75      final String packaging;
76      /**
77       * The full name of the project.
78       */
79      final String name;
80      /**
81       * A detailed description of the project, used by Maven whenever it needs to
82       * describe the project, such as on the website. While this element can be specified as
83       * CDATA to enable the use of HTML tags within the description, it is discouraged to allow
84       * plain text representation. If you need to modify the index page of the generated website,
85       * you are able to specify your own instead of adjusting this text.
86       */
87      final String description;
88      /**
89       * The URL to the project's homepage.
90       * <p><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
91       * project's {@code child.project.url.inherit.append.path="false"}</p>
92       */
93      final String url;
94      /**
95       * When children inherit from project's url, append path or not? Note: While the type
96       * of this field is {@code String} for technical reasons, the semantic type is actually
97       * {@code Boolean}
98       * <p><b>Default value is</b>: {@code true}</p>
99       * @since Maven 3.6.1
100      */
101     final String childProjectUrlInheritAppendPath;
102     /**
103      * Indicates that this project is the root project, located in the upper directory of the source tree.
104      * This is the directory which may contain the .mvn directory.
105      * 
106      * @since Maven 4.0.0
107      */
108     final boolean root;
109     /**
110      * Indicates if the build POM for this project should be preserved or downgraded to the lowest
111      * compatible version.
112      * @since Maven 4.0.0
113      */
114     final boolean preserveModelVersion;
115     /**
116      * The year of the project's inception, specified with 4 digits. This value is
117      * used when generating copyright notices as well as being informational.
118      */
119     final String inceptionYear;
120     /**
121      * This element describes various attributes of the organization to which the
122      * project belongs. These attributes are utilized when documentation is created (for
123      * copyright notices and links).
124      */
125     final Organization organization;
126     /**
127      * This element describes all the licenses for this project.
128      * Each license is described by a {@code license} element, which
129      * is then described by additional elements.
130      * Projects should only list the license(s) that applies to the project
131      * and not the licenses that apply to dependencies.
132      * If multiple licenses are listed, it is assumed that the user can select
133      * any of them, not that they must accept all.
134      */
135     final List<License> licenses;
136     /**
137      * Describes the committers of a project.
138      */
139     final List<Developer> developers;
140     /**
141      * Describes the contributors to a project that are not yet committers.
142      */
143     final List<Contributor> contributors;
144     /**
145      * Contains information about a project's mailing lists.
146      */
147     final List<MailingList> mailingLists;
148     /**
149      * Describes the prerequisites in the build environment for this project.
150      */
151     final Prerequisites prerequisites;
152     /**
153      * Specification for the SCM used by the project, such as CVS, Subversion, etc.
154      */
155     final Scm scm;
156     /**
157      * The project's issue management system information.
158      */
159     final IssueManagement issueManagement;
160     /**
161      * The project's continuous integration information.
162      */
163     final CiManagement ciManagement;
164     /**
165      * Information required to build the project.
166      */
167     final Build build;
168     /**
169      * A listing of project-local build profiles which will modify the build process
170      * when activated.
171      */
172     final List<Profile> profiles;
173     /** Locations (this potentially hides the same name field from the super class) */
174     final Map<Object, InputLocation> locations;
175 
176     /**
177       * Constructor for this class, to be called from its subclasses and {@link Builder}.
178       * @see Builder#build()
179       */
180     protected Model(Builder builder) {
181         super(builder);
182         this.namespaceUri = builder.namespaceUri != null ? builder.namespaceUri : (builder.base != null ? builder.base.namespaceUri : null);
183         this.modelEncoding = builder.modelEncoding != null ? builder.modelEncoding : (builder.base != null ? builder.base.modelEncoding :  "UTF-8");
184         this.pomFile = builder.pomFile != null ? builder.pomFile : (builder.base != null ? builder.base.pomFile : null);
185         this.modelVersion = builder.modelVersion != null ? builder.modelVersion : (builder.base != null ? builder.base.modelVersion : null);
186         this.parent = builder.parent != null ? builder.parent : (builder.base != null ? builder.base.parent : null);
187         this.groupId = builder.groupId != null ? builder.groupId : (builder.base != null ? builder.base.groupId : null);
188         this.artifactId = builder.artifactId != null ? builder.artifactId : (builder.base != null ? builder.base.artifactId : null);
189         this.version = builder.version != null ? builder.version : (builder.base != null ? builder.base.version : null);
190         this.packaging = builder.packaging != null ? builder.packaging : (builder.base != null ? builder.base.packaging : null);
191         this.name = builder.name != null ? builder.name : (builder.base != null ? builder.base.name : null);
192         this.description = builder.description != null ? builder.description : (builder.base != null ? builder.base.description : null);
193         this.url = builder.url != null ? builder.url : (builder.base != null ? builder.base.url : null);
194         this.childProjectUrlInheritAppendPath = builder.childProjectUrlInheritAppendPath != null ? builder.childProjectUrlInheritAppendPath : (builder.base != null ? builder.base.childProjectUrlInheritAppendPath : null);
195         this.root = builder.root != null ? builder.root : (builder.base != null ? builder.base.root : false);
196         this.preserveModelVersion = builder.preserveModelVersion != null ? builder.preserveModelVersion : (builder.base != null ? builder.base.preserveModelVersion : false);
197         this.inceptionYear = builder.inceptionYear != null ? builder.inceptionYear : (builder.base != null ? builder.base.inceptionYear : null);
198         this.organization = builder.organization != null ? builder.organization : (builder.base != null ? builder.base.organization : null);
199         this.licenses = ImmutableCollections.copy(builder.licenses != null ? builder.licenses : (builder.base != null ? builder.base.licenses : null));
200         this.developers = ImmutableCollections.copy(builder.developers != null ? builder.developers : (builder.base != null ? builder.base.developers : null));
201         this.contributors = ImmutableCollections.copy(builder.contributors != null ? builder.contributors : (builder.base != null ? builder.base.contributors : null));
202         this.mailingLists = ImmutableCollections.copy(builder.mailingLists != null ? builder.mailingLists : (builder.base != null ? builder.base.mailingLists : null));
203         this.prerequisites = builder.prerequisites != null ? builder.prerequisites : (builder.base != null ? builder.base.prerequisites : null);
204         this.scm = builder.scm != null ? builder.scm : (builder.base != null ? builder.base.scm : null);
205         this.issueManagement = builder.issueManagement != null ? builder.issueManagement : (builder.base != null ? builder.base.issueManagement : null);
206         this.ciManagement = builder.ciManagement != null ? builder.ciManagement : (builder.base != null ? builder.base.ciManagement : null);
207         this.build = builder.build != null ? builder.build : (builder.base != null ? builder.base.build : null);
208         this.profiles = ImmutableCollections.copy(builder.profiles != null ? builder.profiles : (builder.base != null ? builder.base.profiles : null));
209         Map<Object, InputLocation> newlocs = builder.locations != null ? builder.locations : Collections.emptyMap();
210         Map<Object, InputLocation> oldlocs = builder.base != null && builder.base.locations != null ? builder.base.locations : Collections.emptyMap();
211         Map<Object, InputLocation> mutableLocations = new HashMap<>(super.locations);
212         mutableLocations.put("pomFile", newlocs.containsKey("pomFile") ? newlocs.get("pomFile") : oldlocs.get("pomFile"));
213         mutableLocations.put("modelVersion", newlocs.containsKey("modelVersion") ? newlocs.get("modelVersion") : oldlocs.get("modelVersion"));
214         mutableLocations.put("parent", newlocs.containsKey("parent") ? newlocs.get("parent") : oldlocs.get("parent"));
215         mutableLocations.put("groupId", newlocs.containsKey("groupId") ? newlocs.get("groupId") : oldlocs.get("groupId"));
216         mutableLocations.put("artifactId", newlocs.containsKey("artifactId") ? newlocs.get("artifactId") : oldlocs.get("artifactId"));
217         mutableLocations.put("version", newlocs.containsKey("version") ? newlocs.get("version") : oldlocs.get("version"));
218         mutableLocations.put("packaging", newlocs.containsKey("packaging") ? newlocs.get("packaging") : oldlocs.get("packaging"));
219         mutableLocations.put("name", newlocs.containsKey("name") ? newlocs.get("name") : oldlocs.get("name"));
220         mutableLocations.put("description", newlocs.containsKey("description") ? newlocs.get("description") : oldlocs.get("description"));
221         mutableLocations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
222         mutableLocations.put("childProjectUrlInheritAppendPath", newlocs.containsKey("childProjectUrlInheritAppendPath") ? newlocs.get("childProjectUrlInheritAppendPath") : oldlocs.get("childProjectUrlInheritAppendPath"));
223         mutableLocations.put("root", newlocs.containsKey("root") ? newlocs.get("root") : oldlocs.get("root"));
224         mutableLocations.put("preserveModelVersion", newlocs.containsKey("preserveModelVersion") ? newlocs.get("preserveModelVersion") : oldlocs.get("preserveModelVersion"));
225         mutableLocations.put("inceptionYear", newlocs.containsKey("inceptionYear") ? newlocs.get("inceptionYear") : oldlocs.get("inceptionYear"));
226         mutableLocations.put("organization", newlocs.containsKey("organization") ? newlocs.get("organization") : oldlocs.get("organization"));
227         mutableLocations.put("licenses", newlocs.containsKey("licenses") ? newlocs.get("licenses") : oldlocs.get("licenses"));
228         mutableLocations.put("developers", newlocs.containsKey("developers") ? newlocs.get("developers") : oldlocs.get("developers"));
229         mutableLocations.put("contributors", newlocs.containsKey("contributors") ? newlocs.get("contributors") : oldlocs.get("contributors"));
230         mutableLocations.put("mailingLists", newlocs.containsKey("mailingLists") ? newlocs.get("mailingLists") : oldlocs.get("mailingLists"));
231         mutableLocations.put("prerequisites", newlocs.containsKey("prerequisites") ? newlocs.get("prerequisites") : oldlocs.get("prerequisites"));
232         mutableLocations.put("scm", newlocs.containsKey("scm") ? newlocs.get("scm") : oldlocs.get("scm"));
233         mutableLocations.put("issueManagement", newlocs.containsKey("issueManagement") ? newlocs.get("issueManagement") : oldlocs.get("issueManagement"));
234         mutableLocations.put("ciManagement", newlocs.containsKey("ciManagement") ? newlocs.get("ciManagement") : oldlocs.get("ciManagement"));
235         mutableLocations.put("build", newlocs.containsKey("build") ? newlocs.get("build") : oldlocs.get("build"));
236         mutableLocations.put("profiles", newlocs.containsKey("profiles") ? newlocs.get("profiles") : oldlocs.get("profiles"));
237         this.locations = Collections.unmodifiableMap(mutableLocations);
238     }
239 
240     public String getNamespaceUri() {
241         return namespaceUri;
242     }
243 
244     public String getModelEncoding() {
245         return modelEncoding;
246     }
247 
248     /**
249      * Originating POM file
250      *
251      * @return a {@code Path}
252      */
253     public Path getPomFile() {
254         return this.pomFile;
255     }
256 
257     /**
258      * Declares to which version of project descriptor this POM conforms.
259      *
260      * @return a {@code String}
261      */
262     public String getModelVersion() {
263         return this.modelVersion;
264     }
265 
266     /**
267      * The location of the parent project, if one exists. Values from the parent
268      * project will be the default for this project if they are left unspecified. The location
269      * is given as a group ID, artifact ID and version.
270      *
271      * @return a {@code Parent}
272      */
273     public Parent getParent() {
274         return this.parent;
275     }
276 
277     /**
278      * A universally unique identifier for a project. It is normal to
279      * use a fully-qualified package name to distinguish it from other
280      * projects with a similar name (eg. {@code org.apache.maven}).
281      *
282      * @return a {@code String}
283      */
284     public String getGroupId() {
285         return this.groupId;
286     }
287 
288     /**
289      * The identifier for this artifact that is unique within the group given by the
290      * group ID. An artifact is something that is either produced or used by a project.
291      * Examples of artifacts produced by Maven for a project include: JARs, source and binary
292      * distributions, and WARs.
293      *
294      * @return a {@code String}
295      */
296     public String getArtifactId() {
297         return this.artifactId;
298     }
299 
300     /**
301      * The current version of the artifact produced by this project.
302      *
303      * @return a {@code String}
304      */
305     public String getVersion() {
306         return this.version;
307     }
308 
309     /**
310      * The type of artifact this project produces, for example {@code jar},
311      * {@code war},
312      * {@code ear},
313      * {@code pom}.
314      * Plugins can create their own packaging, and
315      * therefore their own packaging types,
316      * so this list does not contain all possible types.
317      *
318      * @return a {@code String}
319      */
320     public String getPackaging() {
321         return this.packaging;
322     }
323 
324     /**
325      * The full name of the project.
326      *
327      * @return a {@code String}
328      */
329     public String getName() {
330         return this.name;
331     }
332 
333     /**
334      * A detailed description of the project, used by Maven whenever it needs to
335      * describe the project, such as on the website. While this element can be specified as
336      * CDATA to enable the use of HTML tags within the description, it is discouraged to allow
337      * plain text representation. If you need to modify the index page of the generated website,
338      * you are able to specify your own instead of adjusting this text.
339      *
340      * @return a {@code String}
341      */
342     public String getDescription() {
343         return this.description;
344     }
345 
346     /**
347      * The URL to the project's homepage.
348      * <p><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
349      * project's {@code child.project.url.inherit.append.path="false"}</p>
350      *
351      * @return a {@code String}
352      */
353     public String getUrl() {
354         return this.url;
355     }
356 
357     /**
358      * When children inherit from project's url, append path or not? Note: While the type
359      * of this field is {@code String} for technical reasons, the semantic type is actually
360      * {@code Boolean}
361      * <p><b>Default value is</b>: {@code true}</p>
362      * @since Maven 3.6.1
363      *
364      * @return a {@code String}
365      */
366     public String getChildProjectUrlInheritAppendPath() {
367         return this.childProjectUrlInheritAppendPath;
368     }
369 
370     /**
371      * Indicates that this project is the root project, located in the upper directory of the source tree.
372      * This is the directory which may contain the .mvn directory.
373      * 
374      * @since Maven 4.0.0
375      *
376      * @return a {@code boolean}
377      */
378     public boolean isRoot() {
379         return this.root;
380     }
381 
382     /**
383      * Indicates if the build POM for this project should be preserved or downgraded to the lowest
384      * compatible version.
385      * @since Maven 4.0.0
386      *
387      * @return a {@code boolean}
388      */
389     public boolean isPreserveModelVersion() {
390         return this.preserveModelVersion;
391     }
392 
393     /**
394      * The year of the project's inception, specified with 4 digits. This value is
395      * used when generating copyright notices as well as being informational.
396      *
397      * @return a {@code String}
398      */
399     public String getInceptionYear() {
400         return this.inceptionYear;
401     }
402 
403     /**
404      * This element describes various attributes of the organization to which the
405      * project belongs. These attributes are utilized when documentation is created (for
406      * copyright notices and links).
407      *
408      * @return a {@code Organization}
409      */
410     public Organization getOrganization() {
411         return this.organization;
412     }
413 
414     /**
415      * This element describes all the licenses for this project.
416      * Each license is described by a {@code license} element, which
417      * is then described by additional elements.
418      * Projects should only list the license(s) that applies to the project
419      * and not the licenses that apply to dependencies.
420      * If multiple licenses are listed, it is assumed that the user can select
421      * any of them, not that they must accept all.
422      *
423      * @return a {@code List<License>}
424      */
425     @Nonnull
426     public List<License> getLicenses() {
427         return this.licenses;
428     }
429 
430     /**
431      * Describes the committers of a project.
432      *
433      * @return a {@code List<Developer>}
434      */
435     @Nonnull
436     public List<Developer> getDevelopers() {
437         return this.developers;
438     }
439 
440     /**
441      * Describes the contributors to a project that are not yet committers.
442      *
443      * @return a {@code List<Contributor>}
444      */
445     @Nonnull
446     public List<Contributor> getContributors() {
447         return this.contributors;
448     }
449 
450     /**
451      * Contains information about a project's mailing lists.
452      *
453      * @return a {@code List<MailingList>}
454      */
455     @Nonnull
456     public List<MailingList> getMailingLists() {
457         return this.mailingLists;
458     }
459 
460     /**
461      * Describes the prerequisites in the build environment for this project.
462      *
463      * @return a {@code Prerequisites}
464      */
465     public Prerequisites getPrerequisites() {
466         return this.prerequisites;
467     }
468 
469     /**
470      * Specification for the SCM used by the project, such as CVS, Subversion, etc.
471      *
472      * @return a {@code Scm}
473      */
474     public Scm getScm() {
475         return this.scm;
476     }
477 
478     /**
479      * The project's issue management system information.
480      *
481      * @return a {@code IssueManagement}
482      */
483     public IssueManagement getIssueManagement() {
484         return this.issueManagement;
485     }
486 
487     /**
488      * The project's continuous integration information.
489      *
490      * @return a {@code CiManagement}
491      */
492     public CiManagement getCiManagement() {
493         return this.ciManagement;
494     }
495 
496     /**
497      * Information required to build the project.
498      *
499      * @return a {@code Build}
500      */
501     public Build getBuild() {
502         return this.build;
503     }
504 
505     /**
506      * A listing of project-local build profiles which will modify the build process
507      * when activated.
508      *
509      * @return a {@code List<Profile>}
510      */
511     @Nonnull
512     public List<Profile> getProfiles() {
513         return this.profiles;
514     }
515 
516     /**
517      * Gets the location of the specified field in the input source.
518      */
519     public InputLocation getLocation(Object key) {
520         return locations != null ? locations.get(key) : null;
521     }
522 
523     /**
524     * Gets the keys of the locations of the input source.
525     */
526     public Set<Object> getLocationKeys() {
527         return locations != null ? locations.keySet() : null;
528     }
529 
530     /**
531      * Creates a new builder with this object as the basis.
532      *
533      * @return a {@code Builder}
534      */
535     @Nonnull
536     public Builder with() {
537         return newBuilder(this);
538     }
539     /**
540      * Creates a new {@code Model} instance using the specified modules.
541      *
542      * @param modules the new {@code Collection<String>} to use
543      * @return a {@code Model} with the specified modules
544      */
545     @Deprecated
546     @Nonnull
547     public Model withModules(Collection<String> modules) {
548         return newBuilder(this, true).modules(modules).build();
549     }
550     /**
551      * Creates a new {@code Model} instance using the specified subprojects.
552      *
553      * @param subprojects the new {@code Collection<String>} to use
554      * @return a {@code Model} with the specified subprojects
555      */
556     @Nonnull
557     public Model withSubprojects(Collection<String> subprojects) {
558         return newBuilder(this, true).subprojects(subprojects).build();
559     }
560     /**
561      * Creates a new {@code Model} instance using the specified distributionManagement.
562      *
563      * @param distributionManagement the new {@code DistributionManagement} to use
564      * @return a {@code Model} with the specified distributionManagement
565      */
566     @Nonnull
567     public Model withDistributionManagement(DistributionManagement distributionManagement) {
568         return newBuilder(this, true).distributionManagement(distributionManagement).build();
569     }
570     /**
571      * Creates a new {@code Model} instance using the specified properties.
572      *
573      * @param properties the new {@code Map<String, String>} to use
574      * @return a {@code Model} with the specified properties
575      */
576     @Nonnull
577     public Model withProperties(Map<String, String> properties) {
578         return newBuilder(this, true).properties(properties).build();
579     }
580     /**
581      * Creates a new {@code Model} instance using the specified dependencyManagement.
582      *
583      * @param dependencyManagement the new {@code DependencyManagement} to use
584      * @return a {@code Model} with the specified dependencyManagement
585      */
586     @Nonnull
587     public Model withDependencyManagement(DependencyManagement dependencyManagement) {
588         return newBuilder(this, true).dependencyManagement(dependencyManagement).build();
589     }
590     /**
591      * Creates a new {@code Model} instance using the specified dependencies.
592      *
593      * @param dependencies the new {@code Collection<Dependency>} to use
594      * @return a {@code Model} with the specified dependencies
595      */
596     @Nonnull
597     public Model withDependencies(Collection<Dependency> dependencies) {
598         return newBuilder(this, true).dependencies(dependencies).build();
599     }
600     /**
601      * Creates a new {@code Model} instance using the specified repositories.
602      *
603      * @param repositories the new {@code Collection<Repository>} to use
604      * @return a {@code Model} with the specified repositories
605      */
606     @Nonnull
607     public Model withRepositories(Collection<Repository> repositories) {
608         return newBuilder(this, true).repositories(repositories).build();
609     }
610     /**
611      * Creates a new {@code Model} instance using the specified pluginRepositories.
612      *
613      * @param pluginRepositories the new {@code Collection<Repository>} to use
614      * @return a {@code Model} with the specified pluginRepositories
615      */
616     @Nonnull
617     public Model withPluginRepositories(Collection<Repository> pluginRepositories) {
618         return newBuilder(this, true).pluginRepositories(pluginRepositories).build();
619     }
620     /**
621      * Creates a new {@code Model} instance using the specified reporting.
622      *
623      * @param reporting the new {@code Reporting} to use
624      * @return a {@code Model} with the specified reporting
625      */
626     @Nonnull
627     public Model withReporting(Reporting reporting) {
628         return newBuilder(this, true).reporting(reporting).build();
629     }
630     /**
631      * Creates a new {@code Model} instance using the specified pomFile.
632      *
633      * @param pomFile the new {@code Path} to use
634      * @return a {@code Model} with the specified pomFile
635      */
636     @Nonnull
637     public Model withPomFile(Path pomFile) {
638         return newBuilder(this, true).pomFile(pomFile).build();
639     }
640     /**
641      * Creates a new {@code Model} instance using the specified modelVersion.
642      *
643      * @param modelVersion the new {@code String} to use
644      * @return a {@code Model} with the specified modelVersion
645      */
646     @Nonnull
647     public Model withModelVersion(String modelVersion) {
648         return newBuilder(this, true).modelVersion(modelVersion).build();
649     }
650     /**
651      * Creates a new {@code Model} instance using the specified parent.
652      *
653      * @param parent the new {@code Parent} to use
654      * @return a {@code Model} with the specified parent
655      */
656     @Nonnull
657     public Model withParent(Parent parent) {
658         return newBuilder(this, true).parent(parent).build();
659     }
660     /**
661      * Creates a new {@code Model} instance using the specified groupId.
662      *
663      * @param groupId the new {@code String} to use
664      * @return a {@code Model} with the specified groupId
665      */
666     @Nonnull
667     public Model withGroupId(String groupId) {
668         return newBuilder(this, true).groupId(groupId).build();
669     }
670     /**
671      * Creates a new {@code Model} instance using the specified artifactId.
672      *
673      * @param artifactId the new {@code String} to use
674      * @return a {@code Model} with the specified artifactId
675      */
676     @Nonnull
677     public Model withArtifactId(String artifactId) {
678         return newBuilder(this, true).artifactId(artifactId).build();
679     }
680     /**
681      * Creates a new {@code Model} instance using the specified version.
682      *
683      * @param version the new {@code String} to use
684      * @return a {@code Model} with the specified version
685      */
686     @Nonnull
687     public Model withVersion(String version) {
688         return newBuilder(this, true).version(version).build();
689     }
690     /**
691      * Creates a new {@code Model} instance using the specified packaging.
692      *
693      * @param packaging the new {@code String} to use
694      * @return a {@code Model} with the specified packaging
695      */
696     @Nonnull
697     public Model withPackaging(String packaging) {
698         return newBuilder(this, true).packaging(packaging).build();
699     }
700     /**
701      * Creates a new {@code Model} instance using the specified name.
702      *
703      * @param name the new {@code String} to use
704      * @return a {@code Model} with the specified name
705      */
706     @Nonnull
707     public Model withName(String name) {
708         return newBuilder(this, true).name(name).build();
709     }
710     /**
711      * Creates a new {@code Model} instance using the specified description.
712      *
713      * @param description the new {@code String} to use
714      * @return a {@code Model} with the specified description
715      */
716     @Nonnull
717     public Model withDescription(String description) {
718         return newBuilder(this, true).description(description).build();
719     }
720     /**
721      * Creates a new {@code Model} instance using the specified url.
722      *
723      * @param url the new {@code String} to use
724      * @return a {@code Model} with the specified url
725      */
726     @Nonnull
727     public Model withUrl(String url) {
728         return newBuilder(this, true).url(url).build();
729     }
730     /**
731      * Creates a new {@code Model} instance using the specified childProjectUrlInheritAppendPath.
732      *
733      * @param childProjectUrlInheritAppendPath the new {@code String} to use
734      * @return a {@code Model} with the specified childProjectUrlInheritAppendPath
735      */
736     @Nonnull
737     public Model withChildProjectUrlInheritAppendPath(String childProjectUrlInheritAppendPath) {
738         return newBuilder(this, true).childProjectUrlInheritAppendPath(childProjectUrlInheritAppendPath).build();
739     }
740     /**
741      * Creates a new {@code Model} instance using the specified root.
742      *
743      * @param root the new {@code boolean} to use
744      * @return a {@code Model} with the specified root
745      */
746     @Nonnull
747     public Model withRoot(boolean root) {
748         return newBuilder(this, true).root(root).build();
749     }
750     /**
751      * Creates a new {@code Model} instance using the specified preserveModelVersion.
752      *
753      * @param preserveModelVersion the new {@code boolean} to use
754      * @return a {@code Model} with the specified preserveModelVersion
755      */
756     @Nonnull
757     public Model withPreserveModelVersion(boolean preserveModelVersion) {
758         return newBuilder(this, true).preserveModelVersion(preserveModelVersion).build();
759     }
760     /**
761      * Creates a new {@code Model} instance using the specified inceptionYear.
762      *
763      * @param inceptionYear the new {@code String} to use
764      * @return a {@code Model} with the specified inceptionYear
765      */
766     @Nonnull
767     public Model withInceptionYear(String inceptionYear) {
768         return newBuilder(this, true).inceptionYear(inceptionYear).build();
769     }
770     /**
771      * Creates a new {@code Model} instance using the specified organization.
772      *
773      * @param organization the new {@code Organization} to use
774      * @return a {@code Model} with the specified organization
775      */
776     @Nonnull
777     public Model withOrganization(Organization organization) {
778         return newBuilder(this, true).organization(organization).build();
779     }
780     /**
781      * Creates a new {@code Model} instance using the specified licenses.
782      *
783      * @param licenses the new {@code Collection<License>} to use
784      * @return a {@code Model} with the specified licenses
785      */
786     @Nonnull
787     public Model withLicenses(Collection<License> licenses) {
788         return newBuilder(this, true).licenses(licenses).build();
789     }
790     /**
791      * Creates a new {@code Model} instance using the specified developers.
792      *
793      * @param developers the new {@code Collection<Developer>} to use
794      * @return a {@code Model} with the specified developers
795      */
796     @Nonnull
797     public Model withDevelopers(Collection<Developer> developers) {
798         return newBuilder(this, true).developers(developers).build();
799     }
800     /**
801      * Creates a new {@code Model} instance using the specified contributors.
802      *
803      * @param contributors the new {@code Collection<Contributor>} to use
804      * @return a {@code Model} with the specified contributors
805      */
806     @Nonnull
807     public Model withContributors(Collection<Contributor> contributors) {
808         return newBuilder(this, true).contributors(contributors).build();
809     }
810     /**
811      * Creates a new {@code Model} instance using the specified mailingLists.
812      *
813      * @param mailingLists the new {@code Collection<MailingList>} to use
814      * @return a {@code Model} with the specified mailingLists
815      */
816     @Nonnull
817     public Model withMailingLists(Collection<MailingList> mailingLists) {
818         return newBuilder(this, true).mailingLists(mailingLists).build();
819     }
820     /**
821      * Creates a new {@code Model} instance using the specified prerequisites.
822      *
823      * @param prerequisites the new {@code Prerequisites} to use
824      * @return a {@code Model} with the specified prerequisites
825      */
826     @Nonnull
827     public Model withPrerequisites(Prerequisites prerequisites) {
828         return newBuilder(this, true).prerequisites(prerequisites).build();
829     }
830     /**
831      * Creates a new {@code Model} instance using the specified scm.
832      *
833      * @param scm the new {@code Scm} to use
834      * @return a {@code Model} with the specified scm
835      */
836     @Nonnull
837     public Model withScm(Scm scm) {
838         return newBuilder(this, true).scm(scm).build();
839     }
840     /**
841      * Creates a new {@code Model} instance using the specified issueManagement.
842      *
843      * @param issueManagement the new {@code IssueManagement} to use
844      * @return a {@code Model} with the specified issueManagement
845      */
846     @Nonnull
847     public Model withIssueManagement(IssueManagement issueManagement) {
848         return newBuilder(this, true).issueManagement(issueManagement).build();
849     }
850     /**
851      * Creates a new {@code Model} instance using the specified ciManagement.
852      *
853      * @param ciManagement the new {@code CiManagement} to use
854      * @return a {@code Model} with the specified ciManagement
855      */
856     @Nonnull
857     public Model withCiManagement(CiManagement ciManagement) {
858         return newBuilder(this, true).ciManagement(ciManagement).build();
859     }
860     /**
861      * Creates a new {@code Model} instance using the specified build.
862      *
863      * @param build the new {@code Build} to use
864      * @return a {@code Model} with the specified build
865      */
866     @Nonnull
867     public Model withBuild(Build build) {
868         return newBuilder(this, true).build(build).build();
869     }
870     /**
871      * Creates a new {@code Model} instance using the specified profiles.
872      *
873      * @param profiles the new {@code Collection<Profile>} to use
874      * @return a {@code Model} with the specified profiles
875      */
876     @Nonnull
877     public Model withProfiles(Collection<Profile> profiles) {
878         return newBuilder(this, true).profiles(profiles).build();
879     }
880 
881     /**
882      * Creates a new {@code Model} instance.
883      * Equivalent to {@code newInstance(true)}.
884      * @see #newInstance(boolean)
885      *
886      * @return a new {@code Model}
887      */
888     @Nonnull
889     public static Model newInstance() {
890         return newInstance(true);
891     }
892 
893     /**
894      * Creates a new {@code Model} instance using default values or not.
895      * Equivalent to {@code newBuilder(withDefaults).build()}.
896      *
897      * @param withDefaults the boolean indicating whether default values should be used
898      * @return a new {@code Model}
899      */
900     @Nonnull
901     public static Model newInstance(boolean withDefaults) {
902         return newBuilder(withDefaults).build();
903     }
904 
905     /**
906      * Creates a new {@code Model} builder instance.
907      * Equivalent to {@code newBuilder(true)}.
908      * @see #newBuilder(boolean)
909      *
910      * @return a new {@code Builder}
911      */
912     @Nonnull
913     public static Builder newBuilder() {
914         return newBuilder(true);
915     }
916 
917     /**
918      * Creates a new {@code Model} builder instance using default values or not.
919      *
920      * @param withDefaults the boolean indicating whether default values should be used
921      * @return a new {@code Builder}
922      */
923     @Nonnull
924     public static Builder newBuilder(boolean withDefaults) {
925         return new Builder(withDefaults);
926     }
927 
928     /**
929      * Creates a new {@code Model} builder instance using the specified object as a basis.
930      * Equivalent to {@code newBuilder(from, false)}.
931      *
932      * @param from the {@code Model} instance to use as a basis
933      * @return a new {@code Builder}
934      */
935     @Nonnull
936     public static Builder newBuilder(Model from) {
937         return newBuilder(from, false);
938     }
939 
940     /**
941      * Creates a new {@code Model} builder instance using the specified object as a basis.
942      *
943      * @param from the {@code Model} instance to use as a basis
944      * @param forceCopy the boolean indicating if a copy should be forced
945      * @return a new {@code Builder}
946      */
947     @Nonnull
948     public static Builder newBuilder(Model from, boolean forceCopy) {
949         return new Builder(from, forceCopy);
950     }
951 
952     /**
953      * Builder class used to create Model instances.
954      * @see #with()
955      * @see #newBuilder()
956      */
957     @NotThreadSafe
958     public static class Builder
959         extends ModelBase.Builder
960     {
961         Model base;
962         String namespaceUri;
963         String modelEncoding;
964         Path pomFile;
965         String modelVersion;
966         Parent parent;
967         String groupId;
968         String artifactId;
969         String version;
970         String packaging;
971         String name;
972         String description;
973         String url;
974         String childProjectUrlInheritAppendPath;
975         Boolean root;
976         Boolean preserveModelVersion;
977         String inceptionYear;
978         Organization organization;
979         Collection<License> licenses;
980         Collection<Developer> developers;
981         Collection<Contributor> contributors;
982         Collection<MailingList> mailingLists;
983         Prerequisites prerequisites;
984         Scm scm;
985         IssueManagement issueManagement;
986         CiManagement ciManagement;
987         Build build;
988         Collection<Profile> profiles;
989 
990         protected Builder(boolean withDefaults) {
991             super(withDefaults);
992             if (withDefaults) {
993                 this.packaging = "jar";
994                 this.root = false;
995                 this.preserveModelVersion = false;
996             }
997         }
998 
999         protected Builder(Model base, boolean forceCopy) {
1000             super(base, forceCopy);
1001             this.namespaceUri = base.namespaceUri;
1002             this.modelEncoding = base.modelEncoding;
1003             if (forceCopy) {
1004                 this.pomFile = base.pomFile;
1005                 this.modelVersion = base.modelVersion;
1006                 this.parent = base.parent;
1007                 this.groupId = base.groupId;
1008                 this.artifactId = base.artifactId;
1009                 this.version = base.version;
1010                 this.packaging = base.packaging;
1011                 this.name = base.name;
1012                 this.description = base.description;
1013                 this.url = base.url;
1014                 this.childProjectUrlInheritAppendPath = base.childProjectUrlInheritAppendPath;
1015                 this.root = base.root;
1016                 this.preserveModelVersion = base.preserveModelVersion;
1017                 this.inceptionYear = base.inceptionYear;
1018                 this.organization = base.organization;
1019                 this.licenses = base.licenses;
1020                 this.developers = base.developers;
1021                 this.contributors = base.contributors;
1022                 this.mailingLists = base.mailingLists;
1023                 this.prerequisites = base.prerequisites;
1024                 this.scm = base.scm;
1025                 this.issueManagement = base.issueManagement;
1026                 this.ciManagement = base.ciManagement;
1027                 this.build = base.build;
1028                 this.profiles = base.profiles;
1029                 this.locations = base.locations;
1030                 this.importedFrom = base.importedFrom;
1031             } else {
1032                 this.base = base;
1033             }
1034         }
1035 
1036         @Nonnull
1037         public Builder namespaceUri(String namespaceUri) {
1038             this.namespaceUri = namespaceUri;
1039             return this;
1040         }
1041 
1042         @Nonnull
1043         public Builder modelEncoding(String modelEncoding) {
1044             this.modelEncoding = modelEncoding;
1045             return this;
1046         }
1047 
1048         @Deprecated
1049         @Nonnull
1050         public Builder modules(Collection<String> modules) {
1051             this.modules = modules;
1052             return this;
1053         }
1054 
1055         @Nonnull
1056         public Builder subprojects(Collection<String> subprojects) {
1057             this.subprojects = subprojects;
1058             return this;
1059         }
1060 
1061         @Nonnull
1062         public Builder distributionManagement(DistributionManagement distributionManagement) {
1063             this.distributionManagement = distributionManagement;
1064             return this;
1065         }
1066 
1067         @Nonnull
1068         public Builder properties(Map<String, String> properties) {
1069             this.properties = properties;
1070             return this;
1071         }
1072 
1073         @Nonnull
1074         public Builder dependencyManagement(DependencyManagement dependencyManagement) {
1075             this.dependencyManagement = dependencyManagement;
1076             return this;
1077         }
1078 
1079         @Nonnull
1080         public Builder dependencies(Collection<Dependency> dependencies) {
1081             this.dependencies = dependencies;
1082             return this;
1083         }
1084 
1085         @Nonnull
1086         public Builder repositories(Collection<Repository> repositories) {
1087             this.repositories = repositories;
1088             return this;
1089         }
1090 
1091         @Nonnull
1092         public Builder pluginRepositories(Collection<Repository> pluginRepositories) {
1093             this.pluginRepositories = pluginRepositories;
1094             return this;
1095         }
1096 
1097         @Nonnull
1098         public Builder reporting(Reporting reporting) {
1099             this.reporting = reporting;
1100             return this;
1101         }
1102 
1103         @Nonnull
1104         public Builder pomFile(Path pomFile) {
1105             this.pomFile = pomFile;
1106             return this;
1107         }
1108 
1109         @Nonnull
1110         public Builder modelVersion(String modelVersion) {
1111             this.modelVersion = modelVersion;
1112             return this;
1113         }
1114 
1115         @Nonnull
1116         public Builder parent(Parent parent) {
1117             this.parent = parent;
1118             return this;
1119         }
1120 
1121         @Nonnull
1122         public Builder groupId(String groupId) {
1123             this.groupId = groupId;
1124             return this;
1125         }
1126 
1127         @Nonnull
1128         public Builder artifactId(String artifactId) {
1129             this.artifactId = artifactId;
1130             return this;
1131         }
1132 
1133         @Nonnull
1134         public Builder version(String version) {
1135             this.version = version;
1136             return this;
1137         }
1138 
1139         @Nonnull
1140         public Builder packaging(String packaging) {
1141             this.packaging = packaging;
1142             return this;
1143         }
1144 
1145         @Nonnull
1146         public Builder name(String name) {
1147             this.name = name;
1148             return this;
1149         }
1150 
1151         @Nonnull
1152         public Builder description(String description) {
1153             this.description = description;
1154             return this;
1155         }
1156 
1157         @Nonnull
1158         public Builder url(String url) {
1159             this.url = url;
1160             return this;
1161         }
1162 
1163         @Nonnull
1164         public Builder childProjectUrlInheritAppendPath(String childProjectUrlInheritAppendPath) {
1165             this.childProjectUrlInheritAppendPath = childProjectUrlInheritAppendPath;
1166             return this;
1167         }
1168 
1169         @Nonnull
1170         public Builder root(boolean root) {
1171             this.root = root;
1172             return this;
1173         }
1174 
1175         @Nonnull
1176         public Builder preserveModelVersion(boolean preserveModelVersion) {
1177             this.preserveModelVersion = preserveModelVersion;
1178             return this;
1179         }
1180 
1181         @Nonnull
1182         public Builder inceptionYear(String inceptionYear) {
1183             this.inceptionYear = inceptionYear;
1184             return this;
1185         }
1186 
1187         @Nonnull
1188         public Builder organization(Organization organization) {
1189             this.organization = organization;
1190             return this;
1191         }
1192 
1193         @Nonnull
1194         public Builder licenses(Collection<License> licenses) {
1195             this.licenses = licenses;
1196             return this;
1197         }
1198 
1199         @Nonnull
1200         public Builder developers(Collection<Developer> developers) {
1201             this.developers = developers;
1202             return this;
1203         }
1204 
1205         @Nonnull
1206         public Builder contributors(Collection<Contributor> contributors) {
1207             this.contributors = contributors;
1208             return this;
1209         }
1210 
1211         @Nonnull
1212         public Builder mailingLists(Collection<MailingList> mailingLists) {
1213             this.mailingLists = mailingLists;
1214             return this;
1215         }
1216 
1217         @Nonnull
1218         public Builder prerequisites(Prerequisites prerequisites) {
1219             this.prerequisites = prerequisites;
1220             return this;
1221         }
1222 
1223         @Nonnull
1224         public Builder scm(Scm scm) {
1225             this.scm = scm;
1226             return this;
1227         }
1228 
1229         @Nonnull
1230         public Builder issueManagement(IssueManagement issueManagement) {
1231             this.issueManagement = issueManagement;
1232             return this;
1233         }
1234 
1235         @Nonnull
1236         public Builder ciManagement(CiManagement ciManagement) {
1237             this.ciManagement = ciManagement;
1238             return this;
1239         }
1240 
1241         @Nonnull
1242         public Builder build(Build build) {
1243             this.build = build;
1244             return this;
1245         }
1246 
1247         @Nonnull
1248         public Builder profiles(Collection<Profile> profiles) {
1249             this.profiles = profiles;
1250             return this;
1251         }
1252 
1253 
1254         @Nonnull
1255         public Builder location(Object key, InputLocation location) {
1256             if (location != null) {
1257                 if (!(this.locations instanceof HashMap)) {
1258                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
1259                 }
1260                 this.locations.put(key, location);
1261             }
1262             return this;
1263         }
1264 
1265         @Nonnull
1266         public Builder importedFrom(InputLocation importedFrom) {
1267             this.importedFrom = importedFrom;
1268             return this;
1269         }
1270 
1271         @Nonnull
1272         public Model build() {
1273             // this method should not contain any logic other than creating (or reusing) an object in order to ease subclassing
1274             if (base != null
1275                     && (modules == null || modules == base.modules)
1276                     && (subprojects == null || subprojects == base.subprojects)
1277                     && (distributionManagement == null || distributionManagement == base.distributionManagement)
1278                     && (properties == null || properties == base.properties)
1279                     && (dependencyManagement == null || dependencyManagement == base.dependencyManagement)
1280                     && (dependencies == null || dependencies == base.dependencies)
1281                     && (repositories == null || repositories == base.repositories)
1282                     && (pluginRepositories == null || pluginRepositories == base.pluginRepositories)
1283                     && (reporting == null || reporting == base.reporting)
1284                     && (pomFile == null || pomFile == base.pomFile)
1285                     && (modelVersion == null || modelVersion == base.modelVersion)
1286                     && (parent == null || parent == base.parent)
1287                     && (groupId == null || groupId == base.groupId)
1288                     && (artifactId == null || artifactId == base.artifactId)
1289                     && (version == null || version == base.version)
1290                     && (packaging == null || packaging == base.packaging)
1291                     && (name == null || name == base.name)
1292                     && (description == null || description == base.description)
1293                     && (url == null || url == base.url)
1294                     && (childProjectUrlInheritAppendPath == null || childProjectUrlInheritAppendPath == base.childProjectUrlInheritAppendPath)
1295                     && (root == null || root == base.root)
1296                     && (preserveModelVersion == null || preserveModelVersion == base.preserveModelVersion)
1297                     && (inceptionYear == null || inceptionYear == base.inceptionYear)
1298                     && (organization == null || organization == base.organization)
1299                     && (licenses == null || licenses == base.licenses)
1300                     && (developers == null || developers == base.developers)
1301                     && (contributors == null || contributors == base.contributors)
1302                     && (mailingLists == null || mailingLists == base.mailingLists)
1303                     && (prerequisites == null || prerequisites == base.prerequisites)
1304                     && (scm == null || scm == base.scm)
1305                     && (issueManagement == null || issueManagement == base.issueManagement)
1306                     && (ciManagement == null || ciManagement == base.ciManagement)
1307                     && (build == null || build == base.build)
1308                     && (profiles == null || profiles == base.profiles)
1309             ) {
1310                 return base;
1311             }
1312             return new Model(this);
1313         }
1314     }
1315 
1316 
1317             
1318     /**
1319      * Gets the base directory for the corresponding project (if any).
1320      *
1321      * @return The base directory for the corresponding project or {@code null} if this model does not belong to a local
1322      *         project (e.g. describes the metadata of some artifact from the repository).
1323      */
1324     public Path getProjectDirectory() {
1325         return (pomFile != null) ? pomFile.getParent() : null;
1326     }
1327 
1328     /**
1329      * @return the model id as {@code groupId:artifactId:packaging:version}
1330      */
1331     public String getId()
1332     {
1333         StringBuilder id = new StringBuilder( 64 );
1334 
1335         id.append( ( getGroupId() == null ) ? "[inherited]" : getGroupId() );
1336         id.append( ":" );
1337         id.append( getArtifactId() );
1338         id.append( ":" );
1339         id.append( getPackaging() );
1340         id.append( ":" );
1341         id.append( ( getVersion() == null ) ? "[inherited]" : getVersion() );
1342 
1343         return id.toString();
1344     }
1345 
1346     @Override
1347     public String toString()
1348     {
1349         return getId();
1350     }
1351 
1352     public boolean isChildProjectUrlInheritAppendPath()
1353     {
1354         return ( getChildProjectUrlInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildProjectUrlInheritAppendPath() ) : true;
1355     }
1356 
1357             
1358           
1359 }