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 (!Objects.equals(resources, getResources())) {
83 update(getDelegate().withResources(
84 resources.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
85 resources.forEach(e -> e.childrenTracking = this::replace);
86 }
87 }
88
89 public void addResource(Resource resource) {
90 update(getDelegate().withResources(
91 Stream.concat(getDelegate().getResources().stream(), Stream.of(resource.getDelegate()))
92 .collect(Collectors.toList())));
93 resource.childrenTracking = this::replace;
94 }
95
96 public void removeResource(Resource resource) {
97 update(getDelegate().withResources(
98 getDelegate().getResources().stream()
99 .filter(e -> !Objects.equals(e, resource))
100 .collect(Collectors.toList())));
101 resource.childrenTracking = null;
102 }
103
104 @Nonnull
105 public List<Resource> getTestResources() {
106 return new WrapperList<Resource, org.apache.maven.api.model.Resource>(
107 () -> getDelegate().getTestResources(), l -> update(getDelegate().withTestResources(l)),
108 d -> new Resource(d, this), Resource::getDelegate);
109 }
110
111 public void setTestResources(List<Resource> testResources) {
112 if (!Objects.equals(testResources, getTestResources())) {
113 update(getDelegate().withTestResources(
114 testResources.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
115 testResources.forEach(e -> e.childrenTracking = this::replace);
116 }
117 }
118
119 public void addTestResource(Resource testResource) {
120 update(getDelegate().withTestResources(
121 Stream.concat(getDelegate().getTestResources().stream(), Stream.of(testResource.getDelegate()))
122 .collect(Collectors.toList())));
123 testResource.childrenTracking = this::replace;
124 }
125
126 public void removeTestResource(Resource testResource) {
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 return getDelegate().getDirectory();
136 }
137
138 public void setDirectory(String directory) {
139 if (!Objects.equals(directory, getDirectory())) {
140 update(getDelegate().withDirectory(directory));
141 }
142 }
143
144 public String getFinalName() {
145 return getDelegate().getFinalName();
146 }
147
148 public void setFinalName(String finalName) {
149 if (!Objects.equals(finalName, getFinalName())) {
150 update(getDelegate().withFinalName(finalName));
151 }
152 }
153
154 @Nonnull
155 public List<String> getFilters() {
156 return new WrapperList<String, String>(() -> getDelegate().getFilters(), this::setFilters, s -> s, s -> s);
157 }
158
159 public void setFilters(List<String> filters) {
160 if (!Objects.equals(filters, getFilters())) {
161 update(getDelegate().withFilters(filters));
162 }
163 }
164
165 public void addFilter(String filter) {
166 update(getDelegate().withFilters(
167 Stream.concat(getDelegate().getFilters().stream(), Stream.of(filter))
168 .collect(Collectors.toList())));
169 }
170
171 public void removeFilter(String filter) {
172 update(getDelegate().withFilters(
173 getDelegate().getFilters().stream()
174 .filter(e -> !Objects.equals(e, filter))
175 .collect(Collectors.toList())));
176 }
177
178 public InputLocation getLocation(Object key) {
179 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
180 return loc != null ? new InputLocation(loc) : null;
181 }
182
183 public void setLocation(Object key, InputLocation location) {
184 update(org.apache.maven.api.model.BuildBase.newBuilder(getDelegate(), true)
185 .location(key, location.toApiLocation()).build());
186 }
187
188 protected boolean replace(Object oldDelegate, Object newDelegate) {
189 if (super.replace(oldDelegate, newDelegate)) {
190 return true;
191 }
192 if (getDelegate().getResources().contains(oldDelegate)) {
193 List<org.apache.maven.api.model.Resource> list = new ArrayList<>(getDelegate().getResources());
194 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Resource) newDelegate : d);
195 update(getDelegate().withResources(list));
196 return true;
197 }
198 if (getDelegate().getTestResources().contains(oldDelegate)) {
199 List<org.apache.maven.api.model.Resource> list = new ArrayList<>(getDelegate().getTestResources());
200 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Resource) newDelegate : d);
201 update(getDelegate().withTestResources(list));
202 return true;
203 }
204 return false;
205 }
206
207 public static List<org.apache.maven.api.model.BuildBase> buildBaseToApiV4(List<BuildBase> list) {
208 return list != null ? new WrapperList<>(list, BuildBase::getDelegate, BuildBase::new) : null;
209 }
210
211 public static List<BuildBase> buildBaseToApiV3(List<org.apache.maven.api.model.BuildBase> list) {
212 return list != null ? new WrapperList<>(list, BuildBase::new, BuildBase::getDelegate) : null;
213 }
214
215
216
217
218
219
220 public String toString()
221 {
222 return "BuildBase {" + super.toString() + "}";
223 }
224
225
226 }