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