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