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