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 BuildBase
22      extends PluginConfiguration
23      implements Serializable, Cloneable
24  {
25  
26      public BuildBase()
27      {
28          this( org.apache.maven.api.model.BuildBase.newInstance() );
29      }
30  
31      public BuildBase( org.apache.maven.api.model.BuildBase delegate )
32      {
33          this( delegate, null );
34      }
35  
36      public BuildBase( org.apache.maven.api.model.BuildBase delegate, BaseObject parent )
37      {
38          super( delegate, parent );
39      }
40  
41      public BuildBase clone()
42      {
43          return new BuildBase( getDelegate() );
44      }
45  
46      @Override
47      public org.apache.maven.api.model.BuildBase getDelegate()
48      {
49          return ( org.apache.maven.api.model.BuildBase ) 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 BuildBase ) )
60          {
61              return false;
62          }
63          BuildBase that = ( BuildBase ) 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 getDefaultGoal()
74      {
75          return getDelegate().getDefaultGoal();
76      }
77  
78      public void setDefaultGoal( String defaultGoal )
79      {
80          if ( !Objects.equals( defaultGoal, getDelegate().getDefaultGoal() ) )
81          {
82              update( getDelegate().withDefaultGoal( defaultGoal ) );
83          }
84      }
85  
86      @Nonnull
87      public List<Resource> getResources()
88      {
89          return new WrapperList<Resource, org.apache.maven.api.model.Resource>(
90                      () -> getDelegate().getResources(), l -> update( getDelegate().withResources( l ) ),
91                      d -> new Resource( d, this ), Resource::getDelegate );
92      }
93  
94      public void setResources( List<Resource> resources )
95      {
96          if ( !Objects.equals( resources, getDelegate().getResources() ) )
97          {
98              update( getDelegate().withResources(
99                      resources.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) ) );
100             resources.forEach( e -> e.childrenTracking = this::replace );
101         }
102     }
103 
104     public void addResource( Resource resource )
105     {
106         update( getDelegate().withResources(
107                 Stream.concat( getDelegate().getResources().stream(), Stream.of( resource.getDelegate() ) )
108                         .collect( Collectors.toList() ) ) );
109         resource.childrenTracking = this::replace;
110     }
111 
112     public void removeResource( Resource resource )
113     {
114         update( getDelegate().withResources(
115                 getDelegate().getResources().stream()
116                         .filter( e -> !Objects.equals( e, resource ) )
117                         .collect( Collectors.toList() ) ) );
118         resource.childrenTracking = null;
119     }
120 
121     @Nonnull
122     public List<Resource> getTestResources()
123     {
124         return new WrapperList<Resource, org.apache.maven.api.model.Resource>(
125                     () -> getDelegate().getTestResources(), l -> update( getDelegate().withTestResources( l ) ),
126                     d -> new Resource( d, this ), Resource::getDelegate );
127     }
128 
129     public void setTestResources( List<Resource> testResources )
130     {
131         if ( !Objects.equals( testResources, getDelegate().getTestResources() ) )
132         {
133             update( getDelegate().withTestResources(
134                     testResources.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) ) );
135             testResources.forEach( e -> e.childrenTracking = this::replace );
136         }
137     }
138 
139     public void addTestResource( Resource testResource )
140     {
141         update( getDelegate().withTestResources(
142                 Stream.concat( getDelegate().getTestResources().stream(), Stream.of( testResource.getDelegate() ) )
143                         .collect( Collectors.toList() ) ) );
144         testResource.childrenTracking = this::replace;
145     }
146 
147     public void removeTestResource( Resource testResource )
148     {
149         update( getDelegate().withTestResources(
150                 getDelegate().getTestResources().stream()
151                         .filter( e -> !Objects.equals( e, testResource ) )
152                         .collect( Collectors.toList() ) ) );
153         testResource.childrenTracking = null;
154     }
155 
156     public String getDirectory()
157     {
158         return getDelegate().getDirectory();
159     }
160 
161     public void setDirectory( String directory )
162     {
163         if ( !Objects.equals( directory, getDelegate().getDirectory() ) )
164         {
165             update( getDelegate().withDirectory( directory ) );
166         }
167     }
168 
169     public String getFinalName()
170     {
171         return getDelegate().getFinalName();
172     }
173 
174     public void setFinalName( String finalName )
175     {
176         if ( !Objects.equals( finalName, getDelegate().getFinalName() ) )
177         {
178             update( getDelegate().withFinalName( finalName ) );
179         }
180     }
181 
182     @Nonnull
183     public List<String> getFilters()
184     {
185         return new WrapperList<String, String>( () -> getDelegate().getFilters(), this::setFilters, s -> s, s -> s );
186     }
187 
188     public void setFilters( List<String> filters )
189     {
190         if ( !Objects.equals( filters, getDelegate().getFilters() ) )
191         {
192             update( getDelegate().withFilters( filters ) );
193         }
194     }
195 
196     public void addFilter( String filter )
197     {
198         update( getDelegate().withFilters(
199                 Stream.concat( getDelegate().getFilters().stream(), Stream.of( filter ) )
200                         .collect( Collectors.toList() ) ) );
201     }
202 
203     public void removeFilter( String filter )
204     {
205         update( getDelegate().withFilters(
206                 getDelegate().getFilters().stream()
207                         .filter( e -> !Objects.equals( e, filter ) )
208                         .collect( Collectors.toList() ) ) );
209     }
210 
211     public InputLocation getLocation( Object key )
212     {
213         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation( key );
214         return loc != null ? new InputLocation( loc ) : null;
215     }
216 
217     public void setLocation( Object key, InputLocation location )
218     {
219         update( org.apache.maven.api.model.BuildBase.newBuilder( getDelegate(), true )
220                         .location( key, location.toApiLocation() ).build() );
221     }
222 
223     protected boolean replace( Object oldDelegate, Object newDelegate )
224     {
225         if ( super.replace( oldDelegate, newDelegate ) )
226         {
227             return true;
228         }
229         if ( getDelegate().getResources().contains( oldDelegate ) )
230         {
231             List<org.apache.maven.api.model.Resource> list = new ArrayList<>( getDelegate().getResources() );
232             list.replaceAll( d -> d == oldDelegate ? ( org.apache.maven.api.model.Resource ) newDelegate : d );
233             update( getDelegate().withResources( list ) );
234             return true;
235         }
236         if ( getDelegate().getTestResources().contains( oldDelegate ) )
237         {
238             List<org.apache.maven.api.model.Resource> list = new ArrayList<>( getDelegate().getTestResources() );
239             list.replaceAll( d -> d == oldDelegate ? ( org.apache.maven.api.model.Resource ) newDelegate : d );
240             update( getDelegate().withTestResources( list ) );
241             return true;
242         }
243         return false;
244     }
245 
246     public static List<org.apache.maven.api.model.BuildBase> buildBaseToApiV4( List<BuildBase> list )
247     {
248         return list != null ? new WrapperList<>( list, BuildBase::getDelegate, BuildBase::new ) : null;
249     }
250 
251     public static List<BuildBase> buildBaseToApiV3( List<org.apache.maven.api.model.BuildBase> list )
252     {
253         return list != null ? new WrapperList<>( list, BuildBase::new, BuildBase::getDelegate ) : null;
254     }
255 
256 
257             
258     /**
259      * @see java.lang.Object#toString()
260      */
261     public String toString()
262     {
263         return "BuildBase {" + super.toString() + "}";
264     }
265             
266           
267 }