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