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