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