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