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