View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model-v3.vm
3   //  template, any modifications will be overwritten.
4   // ==============================================================
5   package org.apache.maven.model;
6   
7   import java.io.Serializable;
8   import java.nio.file.Path;
9   import java.util.AbstractList;
10  import java.util.ArrayList;
11  import java.util.Collections;
12  import java.util.HashMap;
13  import java.util.List;
14  import java.util.Map;
15  import java.util.Objects;
16  import java.util.Properties;
17  import java.util.stream.Collectors;
18  import java.util.stream.Stream;
19  import org.apache.maven.api.annotations.Generated;
20  import org.apache.maven.api.annotations.Nonnull;
21  import org.codehaus.plexus.util.xml.Xpp3Dom;
22  
23  @Generated
24  public class Model
25      extends ModelBase
26      implements Serializable, Cloneable
27  {
28  
29      public Model() {
30          this(org.apache.maven.api.model.Model.newInstance());
31      }
32  
33      public Model(org.apache.maven.api.model.Model delegate) {
34          this(delegate, null);
35      }
36  
37      public Model(org.apache.maven.api.model.Model delegate, BaseObject parent) {
38          super(delegate, parent);
39      }
40  
41      public Model clone(){
42          return new Model(getDelegate());
43      }
44  
45      @Override
46      public org.apache.maven.api.model.Model getDelegate() {
47          return (org.apache.maven.api.model.Model) super.getDelegate();
48      }
49  
50      @Override
51      public boolean equals(Object o) {
52          if (this == o) {
53              return true;
54          }
55          if (o == null || !(o instanceof Model)) {
56              return false;
57          }
58          Model that = (Model) o;
59          return Objects.equals(this.delegate, that.delegate);
60      }
61  
62      @Override
63      public int hashCode() {
64          return getDelegate().hashCode();
65      }
66  
67      public String getModelEncoding() {
68          return getDelegate().getModelEncoding();
69      }
70  
71      public String getModelVersion() {
72          return getDelegate().getModelVersion();
73      }
74  
75      public void setModelVersion(String modelVersion) {
76          if (!Objects.equals(modelVersion, getModelVersion())) {
77              update(getDelegate().withModelVersion(modelVersion));
78          }
79      }
80  
81      public Parent getParent() {
82          return getDelegate().getParent() != null ? new Parent(getDelegate().getParent(), this) : null;
83      }
84  
85      public void setParent(Parent parent) {
86          if (!Objects.equals(parent, getParent())) {
87              update(getDelegate().withParent(parent.getDelegate()));
88              parent.childrenTracking = this::replace;
89          }
90      }
91  
92      public String getGroupId() {
93          return getDelegate().getGroupId();
94      }
95  
96      public void setGroupId(String groupId) {
97          if (!Objects.equals(groupId, getGroupId())) {
98              update(getDelegate().withGroupId(groupId));
99          }
100     }
101 
102     public String getArtifactId() {
103         return getDelegate().getArtifactId();
104     }
105 
106     public void setArtifactId(String artifactId) {
107         if (!Objects.equals(artifactId, getArtifactId())) {
108             update(getDelegate().withArtifactId(artifactId));
109         }
110     }
111 
112     public String getVersion() {
113         return getDelegate().getVersion();
114     }
115 
116     public void setVersion(String version) {
117         if (!Objects.equals(version, getVersion())) {
118             update(getDelegate().withVersion(version));
119         }
120     }
121 
122     public String getPackaging() {
123         return getDelegate().getPackaging();
124     }
125 
126     public void setPackaging(String packaging) {
127         if (!Objects.equals(packaging, getPackaging())) {
128             update(getDelegate().withPackaging(packaging));
129         }
130     }
131 
132     public String getName() {
133         return getDelegate().getName();
134     }
135 
136     public void setName(String name) {
137         if (!Objects.equals(name, getName())) {
138             update(getDelegate().withName(name));
139         }
140     }
141 
142     public String getDescription() {
143         return getDelegate().getDescription();
144     }
145 
146     public void setDescription(String description) {
147         if (!Objects.equals(description, getDescription())) {
148             update(getDelegate().withDescription(description));
149         }
150     }
151 
152     public String getUrl() {
153         return getDelegate().getUrl();
154     }
155 
156     public void setUrl(String url) {
157         if (!Objects.equals(url, getUrl())) {
158             update(getDelegate().withUrl(url));
159         }
160     }
161 
162     public String getChildProjectUrlInheritAppendPath() {
163         return getDelegate().getChildProjectUrlInheritAppendPath();
164     }
165 
166     public void setChildProjectUrlInheritAppendPath(String childProjectUrlInheritAppendPath) {
167         if (!Objects.equals(childProjectUrlInheritAppendPath, getChildProjectUrlInheritAppendPath())) {
168             update(getDelegate().withChildProjectUrlInheritAppendPath(childProjectUrlInheritAppendPath));
169         }
170     }
171 
172     public boolean isRoot() {
173         return getDelegate().isRoot();
174     }
175 
176     public void setRoot(boolean root) {
177         if (!Objects.equals(root, isRoot())) {
178             update(getDelegate().withRoot(root));
179         }
180     }
181 
182     public String getInceptionYear() {
183         return getDelegate().getInceptionYear();
184     }
185 
186     public void setInceptionYear(String inceptionYear) {
187         if (!Objects.equals(inceptionYear, getInceptionYear())) {
188             update(getDelegate().withInceptionYear(inceptionYear));
189         }
190     }
191 
192     public Organization getOrganization() {
193         return getDelegate().getOrganization() != null ? new Organization(getDelegate().getOrganization(), this) : null;
194     }
195 
196     public void setOrganization(Organization organization) {
197         if (!Objects.equals(organization, getOrganization())) {
198             update(getDelegate().withOrganization(organization.getDelegate()));
199             organization.childrenTracking = this::replace;
200         }
201     }
202 
203     @Nonnull
204     public List<License> getLicenses() {
205         return new WrapperList<License, org.apache.maven.api.model.License>(
206                     () -> getDelegate().getLicenses(), l -> update(getDelegate().withLicenses(l)),
207                     d -> new License(d, this), License::getDelegate);
208     }
209 
210     public void setLicenses(List<License> licenses) {
211         if (!Objects.equals(licenses, getLicenses())) {
212             update(getDelegate().withLicenses(
213                    licenses.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
214             licenses.forEach(e -> e.childrenTracking = this::replace);
215         }
216     }
217 
218     public void addLicense(License license) {
219         update(getDelegate().withLicenses(
220                Stream.concat(getDelegate().getLicenses().stream(), Stream.of(license.getDelegate()))
221                         .collect(Collectors.toList())));
222         license.childrenTracking = this::replace;
223     }
224 
225     public void removeLicense(License license) {
226         update(getDelegate().withLicenses(
227                getDelegate().getLicenses().stream()
228                         .filter(e -> !Objects.equals(e, license))
229                         .collect(Collectors.toList())));
230         license.childrenTracking = null;
231     }
232 
233     @Nonnull
234     public List<Developer> getDevelopers() {
235         return new WrapperList<Developer, org.apache.maven.api.model.Developer>(
236                     () -> getDelegate().getDevelopers(), l -> update(getDelegate().withDevelopers(l)),
237                     d -> new Developer(d, this), Developer::getDelegate);
238     }
239 
240     public void setDevelopers(List<Developer> developers) {
241         if (!Objects.equals(developers, getDevelopers())) {
242             update(getDelegate().withDevelopers(
243                    developers.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
244             developers.forEach(e -> e.childrenTracking = this::replace);
245         }
246     }
247 
248     public void addDeveloper(Developer developer) {
249         update(getDelegate().withDevelopers(
250                Stream.concat(getDelegate().getDevelopers().stream(), Stream.of(developer.getDelegate()))
251                         .collect(Collectors.toList())));
252         developer.childrenTracking = this::replace;
253     }
254 
255     public void removeDeveloper(Developer developer) {
256         update(getDelegate().withDevelopers(
257                getDelegate().getDevelopers().stream()
258                         .filter(e -> !Objects.equals(e, developer))
259                         .collect(Collectors.toList())));
260         developer.childrenTracking = null;
261     }
262 
263     @Nonnull
264     public List<Contributor> getContributors() {
265         return new WrapperList<Contributor, org.apache.maven.api.model.Contributor>(
266                     () -> getDelegate().getContributors(), l -> update(getDelegate().withContributors(l)),
267                     d -> new Contributor(d, this), Contributor::getDelegate);
268     }
269 
270     public void setContributors(List<Contributor> contributors) {
271         if (!Objects.equals(contributors, getContributors())) {
272             update(getDelegate().withContributors(
273                    contributors.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
274             contributors.forEach(e -> e.childrenTracking = this::replace);
275         }
276     }
277 
278     public void addContributor(Contributor contributor) {
279         update(getDelegate().withContributors(
280                Stream.concat(getDelegate().getContributors().stream(), Stream.of(contributor.getDelegate()))
281                         .collect(Collectors.toList())));
282         contributor.childrenTracking = this::replace;
283     }
284 
285     public void removeContributor(Contributor contributor) {
286         update(getDelegate().withContributors(
287                getDelegate().getContributors().stream()
288                         .filter(e -> !Objects.equals(e, contributor))
289                         .collect(Collectors.toList())));
290         contributor.childrenTracking = null;
291     }
292 
293     @Nonnull
294     public List<MailingList> getMailingLists() {
295         return new WrapperList<MailingList, org.apache.maven.api.model.MailingList>(
296                     () -> getDelegate().getMailingLists(), l -> update(getDelegate().withMailingLists(l)),
297                     d -> new MailingList(d, this), MailingList::getDelegate);
298     }
299 
300     public void setMailingLists(List<MailingList> mailingLists) {
301         if (!Objects.equals(mailingLists, getMailingLists())) {
302             update(getDelegate().withMailingLists(
303                    mailingLists.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
304             mailingLists.forEach(e -> e.childrenTracking = this::replace);
305         }
306     }
307 
308     public void addMailingList(MailingList mailingList) {
309         update(getDelegate().withMailingLists(
310                Stream.concat(getDelegate().getMailingLists().stream(), Stream.of(mailingList.getDelegate()))
311                         .collect(Collectors.toList())));
312         mailingList.childrenTracking = this::replace;
313     }
314 
315     public void removeMailingList(MailingList mailingList) {
316         update(getDelegate().withMailingLists(
317                getDelegate().getMailingLists().stream()
318                         .filter(e -> !Objects.equals(e, mailingList))
319                         .collect(Collectors.toList())));
320         mailingList.childrenTracking = null;
321     }
322 
323     public Prerequisites getPrerequisites() {
324         return getDelegate().getPrerequisites() != null ? new Prerequisites(getDelegate().getPrerequisites(), this) : null;
325     }
326 
327     public void setPrerequisites(Prerequisites prerequisites) {
328         if (!Objects.equals(prerequisites, getPrerequisites())) {
329             update(getDelegate().withPrerequisites(prerequisites.getDelegate()));
330             prerequisites.childrenTracking = this::replace;
331         }
332     }
333 
334     public Scm getScm() {
335         return getDelegate().getScm() != null ? new Scm(getDelegate().getScm(), this) : null;
336     }
337 
338     public void setScm(Scm scm) {
339         if (!Objects.equals(scm, getScm())) {
340             update(getDelegate().withScm(scm.getDelegate()));
341             scm.childrenTracking = this::replace;
342         }
343     }
344 
345     public IssueManagement getIssueManagement() {
346         return getDelegate().getIssueManagement() != null ? new IssueManagement(getDelegate().getIssueManagement(), this) : null;
347     }
348 
349     public void setIssueManagement(IssueManagement issueManagement) {
350         if (!Objects.equals(issueManagement, getIssueManagement())) {
351             update(getDelegate().withIssueManagement(issueManagement.getDelegate()));
352             issueManagement.childrenTracking = this::replace;
353         }
354     }
355 
356     public CiManagement getCiManagement() {
357         return getDelegate().getCiManagement() != null ? new CiManagement(getDelegate().getCiManagement(), this) : null;
358     }
359 
360     public void setCiManagement(CiManagement ciManagement) {
361         if (!Objects.equals(ciManagement, getCiManagement())) {
362             update(getDelegate().withCiManagement(ciManagement.getDelegate()));
363             ciManagement.childrenTracking = this::replace;
364         }
365     }
366 
367     public Build getBuild() {
368         return getDelegate().getBuild() != null ? new Build(getDelegate().getBuild(), this) : null;
369     }
370 
371     public void setBuild(Build build) {
372         if (!Objects.equals(build, getBuild())) {
373             update(getDelegate().withBuild(build.getDelegate()));
374             build.childrenTracking = this::replace;
375         }
376     }
377 
378     @Nonnull
379     public List<Profile> getProfiles() {
380         return new WrapperList<Profile, org.apache.maven.api.model.Profile>(
381                     () -> getDelegate().getProfiles(), l -> update(getDelegate().withProfiles(l)),
382                     d -> new Profile(d, this), Profile::getDelegate);
383     }
384 
385     public void setProfiles(List<Profile> profiles) {
386         if (!Objects.equals(profiles, getProfiles())) {
387             update(getDelegate().withProfiles(
388                    profiles.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
389             profiles.forEach(e -> e.childrenTracking = this::replace);
390         }
391     }
392 
393     public void addProfile(Profile profile) {
394         update(getDelegate().withProfiles(
395                Stream.concat(getDelegate().getProfiles().stream(), Stream.of(profile.getDelegate()))
396                         .collect(Collectors.toList())));
397         profile.childrenTracking = this::replace;
398     }
399 
400     public void removeProfile(Profile profile) {
401         update(getDelegate().withProfiles(
402                getDelegate().getProfiles().stream()
403                         .filter(e -> !Objects.equals(e, profile))
404                         .collect(Collectors.toList())));
405         profile.childrenTracking = null;
406     }
407 
408     public InputLocation getLocation(Object key) {
409         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
410         return loc != null ? new InputLocation(loc) : null;
411     }
412 
413     public void setLocation(Object key, InputLocation location) {
414         update(org.apache.maven.api.model.Model.newBuilder(getDelegate(), true)
415                         .location(key, location.toApiLocation()).build());
416     }
417 
418     protected boolean replace(Object oldDelegate, Object newDelegate) {
419         if (super.replace(oldDelegate, newDelegate)) {
420             return true;
421         }
422         if (oldDelegate == getDelegate().getParent()) {
423             update(getDelegate().withParent((org.apache.maven.api.model.Parent) newDelegate));
424             return true;
425         }
426         if (oldDelegate == getDelegate().getOrganization()) {
427             update(getDelegate().withOrganization((org.apache.maven.api.model.Organization) newDelegate));
428             return true;
429         }
430         if (getDelegate().getLicenses().contains(oldDelegate)) {
431             List<org.apache.maven.api.model.License> list = new ArrayList<>(getDelegate().getLicenses());
432             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.License) newDelegate : d);
433             update(getDelegate().withLicenses(list));
434             return true;
435         }
436         if (getDelegate().getDevelopers().contains(oldDelegate)) {
437             List<org.apache.maven.api.model.Developer> list = new ArrayList<>(getDelegate().getDevelopers());
438             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Developer) newDelegate : d);
439             update(getDelegate().withDevelopers(list));
440             return true;
441         }
442         if (getDelegate().getContributors().contains(oldDelegate)) {
443             List<org.apache.maven.api.model.Contributor> list = new ArrayList<>(getDelegate().getContributors());
444             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Contributor) newDelegate : d);
445             update(getDelegate().withContributors(list));
446             return true;
447         }
448         if (getDelegate().getMailingLists().contains(oldDelegate)) {
449             List<org.apache.maven.api.model.MailingList> list = new ArrayList<>(getDelegate().getMailingLists());
450             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.MailingList) newDelegate : d);
451             update(getDelegate().withMailingLists(list));
452             return true;
453         }
454         if (oldDelegate == getDelegate().getPrerequisites()) {
455             update(getDelegate().withPrerequisites((org.apache.maven.api.model.Prerequisites) newDelegate));
456             return true;
457         }
458         if (oldDelegate == getDelegate().getScm()) {
459             update(getDelegate().withScm((org.apache.maven.api.model.Scm) newDelegate));
460             return true;
461         }
462         if (oldDelegate == getDelegate().getIssueManagement()) {
463             update(getDelegate().withIssueManagement((org.apache.maven.api.model.IssueManagement) newDelegate));
464             return true;
465         }
466         if (oldDelegate == getDelegate().getCiManagement()) {
467             update(getDelegate().withCiManagement((org.apache.maven.api.model.CiManagement) newDelegate));
468             return true;
469         }
470         if (oldDelegate == getDelegate().getBuild()) {
471             update(getDelegate().withBuild((org.apache.maven.api.model.Build) newDelegate));
472             return true;
473         }
474         if (getDelegate().getProfiles().contains(oldDelegate)) {
475             List<org.apache.maven.api.model.Profile> list = new ArrayList<>(getDelegate().getProfiles());
476             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Profile) newDelegate : d);
477             update(getDelegate().withProfiles(list));
478             return true;
479         }
480         return false;
481     }
482 
483     public static List<org.apache.maven.api.model.Model> modelToApiV4(List<Model> list) {
484         return list != null ? new WrapperList<>(list, Model::getDelegate, Model::new) : null;
485     }
486 
487     public static List<Model> modelToApiV3(List<org.apache.maven.api.model.Model> list) {
488         return list != null ? new WrapperList<>(list, Model::new, Model::getDelegate) : null;
489     }
490 
491 
492             
493     /**
494      * Gets the POM file for the corresponding project (if any).
495      *
496      * @return The POM file from which this model originated or {@code null} if this model does not belong to a local
497      *         project (e.g. describes the metadata of some artifact from the repository).
498      */
499     public java.io.File getPomFile()
500     {
501         return ( getDelegate().getPomFile() != null ) ? getDelegate().getPomFile().toFile() : null;
502     }
503 
504     public void setPomFile( java.io.File pomFile )
505     {
506         update( getDelegate().withPomFile( pomFile != null ? pomFile.toPath() : null ) );
507     }
508 
509     public void setModelEncoding( String modelEncoding )
510     {
511         update( getDelegate().with().modelEncoding( modelEncoding ).build() );
512     }
513 
514     /**
515      * Gets the base directory for the corresponding project (if any).
516      *
517      * @return The base directory for the corresponding project or {@code null} if this model does not belong to a local
518      *         project (e.g. describes the metadata of some artifact from the repository).
519      */
520     public java.io.File getProjectDirectory()
521     {
522         return ( getDelegate().getProjectDirectory() != null ) ? getDelegate().getProjectDirectory().toFile() : null;
523     }
524 
525     /**
526      * @return the model id as {@code groupId:artifactId:packaging:version}
527      */
528     public String getId()
529     {
530         StringBuilder id = new StringBuilder( 64 );
531 
532         id.append( ( getGroupId() == null ) ? "[inherited]" : getGroupId() );
533         id.append( ":" );
534         id.append( getArtifactId() );
535         id.append( ":" );
536         id.append( getPackaging() );
537         id.append( ":" );
538         id.append( ( getVersion() == null ) ? "[inherited]" : getVersion() );
539 
540         return id.toString();
541     }
542 
543     @Override
544     public String toString()
545     {
546         return getId();
547     }
548 
549     public boolean isChildProjectUrlInheritAppendPath()
550     {
551         return getDelegate().isChildProjectUrlInheritAppendPath();
552     }
553 
554     public void setChildProjectUrlInheritAppendPath( boolean childProjectUrlInheritAppendPath )
555     {
556         delegate = getDelegate().withChildProjectUrlInheritAppendPath( String.valueOf( childProjectUrlInheritAppendPath ) );
557     }
558 
559             
560           
561 }