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