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