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.util.AbstractList;
8   import java.util.ArrayList;
9   import java.util.Collections;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
13  import java.util.Objects;
14  import java.util.stream.Collectors;
15  import java.util.stream.Stream;
16  import org.apache.maven.api.annotations.Generated;
17  import org.apache.maven.api.annotations.Nonnull;
18  
19  @Generated
20  public class Build
21      extends BuildBase
22      implements Serializable, Cloneable
23  {
24  
25      public Build()
26      {
27          this( org.apache.maven.api.model.Build.newInstance() );
28      }
29  
30      public Build( org.apache.maven.api.model.Build delegate )
31      {
32          this( delegate, null );
33      }
34  
35      public Build( org.apache.maven.api.model.Build delegate, BaseObject parent )
36      {
37          super( delegate, parent );
38      }
39  
40      public Build clone()
41      {
42          return new Build( getDelegate() );
43      }
44  
45      @Override
46      public org.apache.maven.api.model.Build getDelegate()
47      {
48          return ( org.apache.maven.api.model.Build ) super.getDelegate();
49      }
50  
51      public String getSourceDirectory()
52      {
53          return getDelegate().getSourceDirectory();
54      }
55  
56      public void setSourceDirectory( String sourceDirectory )
57      {
58          if ( !Objects.equals( sourceDirectory, getDelegate().getSourceDirectory() ) )
59          {
60              update( getDelegate().withSourceDirectory( sourceDirectory ) );
61          }
62      }
63  
64      public String getScriptSourceDirectory()
65      {
66          return getDelegate().getScriptSourceDirectory();
67      }
68  
69      public void setScriptSourceDirectory( String scriptSourceDirectory )
70      {
71          if ( !Objects.equals( scriptSourceDirectory, getDelegate().getScriptSourceDirectory() ) )
72          {
73              update( getDelegate().withScriptSourceDirectory( scriptSourceDirectory ) );
74          }
75      }
76  
77      public String getTestSourceDirectory()
78      {
79          return getDelegate().getTestSourceDirectory();
80      }
81  
82      public void setTestSourceDirectory( String testSourceDirectory )
83      {
84          if ( !Objects.equals( testSourceDirectory, getDelegate().getTestSourceDirectory() ) )
85          {
86              update( getDelegate().withTestSourceDirectory( testSourceDirectory ) );
87          }
88      }
89  
90      public String getOutputDirectory()
91      {
92          return getDelegate().getOutputDirectory();
93      }
94  
95      public void setOutputDirectory( String outputDirectory )
96      {
97          if ( !Objects.equals( outputDirectory, getDelegate().getOutputDirectory() ) )
98          {
99              update( getDelegate().withOutputDirectory( outputDirectory ) );
100         }
101     }
102 
103     public String getTestOutputDirectory()
104     {
105         return getDelegate().getTestOutputDirectory();
106     }
107 
108     public void setTestOutputDirectory( String testOutputDirectory )
109     {
110         if ( !Objects.equals( testOutputDirectory, getDelegate().getTestOutputDirectory() ) )
111         {
112             update( getDelegate().withTestOutputDirectory( testOutputDirectory ) );
113         }
114     }
115 
116     @Nonnull
117     public List<Extension> getExtensions()
118     {
119         return new WrapperList<Extension, org.apache.maven.api.model.Extension>(
120                     () -> getDelegate().getExtensions(), l -> update( getDelegate().withExtensions( l ) ),
121                     d -> new Extension( d, this ), Extension::getDelegate );
122     }
123 
124     public void setExtensions( List<Extension> extensions )
125     {
126         if ( !Objects.equals( extensions, getDelegate().getExtensions() ) )
127         {
128             update( getDelegate().withExtensions(
129                     extensions.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) ) );
130             extensions.forEach( e -> e.childrenTracking = this::replace );
131         }
132     }
133 
134     public void addExtension( Extension extension )
135     {
136         update( getDelegate().withExtensions(
137                 Stream.concat( getDelegate().getExtensions().stream(), Stream.of( extension.getDelegate() ) )
138                         .collect( Collectors.toList() ) ) );
139         extension.childrenTracking = this::replace;
140     }
141 
142     public void removeExtension( Extension extension )
143     {
144         update( getDelegate().withExtensions(
145                 getDelegate().getExtensions().stream()
146                         .filter( e -> !Objects.equals( e, extension ) )
147                         .collect( Collectors.toList() ) ) );
148         extension.childrenTracking = null;
149     }
150 
151     public InputLocation getLocation( Object key )
152     {
153         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation( key );
154         return loc != null ? new InputLocation( loc ) : null;
155     }
156 
157     public void setLocation( Object key, InputLocation location )
158     {
159         update( org.apache.maven.api.model.Build.newBuilder( getDelegate(), true )
160                         .location( key, location.toApiLocation() ).build() );
161     }
162 
163     protected boolean replace( Object oldDelegate, Object newDelegate )
164     {
165         if ( super.replace( oldDelegate, newDelegate ) )
166         {
167             return true;
168         }
169         if ( getDelegate().getExtensions().contains( oldDelegate ) )
170         {
171             List<org.apache.maven.api.model.Extension> list = new ArrayList<>( getDelegate().getExtensions() );
172             list.replaceAll( d -> d == oldDelegate ? ( org.apache.maven.api.model.Extension ) newDelegate : d );
173             update( getDelegate().withExtensions( list ) );
174             return true;
175         }
176         return false;
177     }
178 
179     public static List<org.apache.maven.api.model.Build> buildToApiV4( List<Build> list )
180     {
181         return list != null ? new WrapperList<>( list, Build::getDelegate, Build::new ) : null;
182     }
183 
184     public static List<Build> buildToApiV3( List<org.apache.maven.api.model.Build> list )
185     {
186         return list != null ? new WrapperList<>( list, Build::new, Build::getDelegate ) : null;
187     }
188 
189 }