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