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.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 Build
23 extends BuildBase
24 implements Serializable, Cloneable
25 {
26
27 public Build() {
28 this(org.apache.maven.api.model.Build.newInstance());
29 }
30
31 public Build(org.apache.maven.api.model.Build delegate) {
32 this(delegate, null);
33 }
34
35 public Build(org.apache.maven.api.model.Build delegate, BaseObject parent) {
36 super(delegate, parent);
37 }
38
39 public Build clone(){
40 return new Build(getDelegate());
41 }
42
43 @Override
44 public org.apache.maven.api.model.Build getDelegate() {
45 return (org.apache.maven.api.model.Build) 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 Build)) {
54 return false;
55 }
56 Build that = (Build) 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 getSourceDirectory() {
66 return getDelegate().getSourceDirectory();
67 }
68
69 public void setSourceDirectory(String sourceDirectory) {
70 if (!Objects.equals(sourceDirectory, getSourceDirectory())) {
71 update(getDelegate().withSourceDirectory(sourceDirectory));
72 }
73 }
74
75 public String getScriptSourceDirectory() {
76 return getDelegate().getScriptSourceDirectory();
77 }
78
79 public void setScriptSourceDirectory(String scriptSourceDirectory) {
80 if (!Objects.equals(scriptSourceDirectory, getScriptSourceDirectory())) {
81 update(getDelegate().withScriptSourceDirectory(scriptSourceDirectory));
82 }
83 }
84
85 public String getTestSourceDirectory() {
86 return getDelegate().getTestSourceDirectory();
87 }
88
89 public void setTestSourceDirectory(String testSourceDirectory) {
90 if (!Objects.equals(testSourceDirectory, getTestSourceDirectory())) {
91 update(getDelegate().withTestSourceDirectory(testSourceDirectory));
92 }
93 }
94
95 public String getOutputDirectory() {
96 return getDelegate().getOutputDirectory();
97 }
98
99 public void setOutputDirectory(String outputDirectory) {
100 if (!Objects.equals(outputDirectory, getOutputDirectory())) {
101 update(getDelegate().withOutputDirectory(outputDirectory));
102 }
103 }
104
105 public String getTestOutputDirectory() {
106 return getDelegate().getTestOutputDirectory();
107 }
108
109 public void setTestOutputDirectory(String testOutputDirectory) {
110 if (!Objects.equals(testOutputDirectory, getTestOutputDirectory())) {
111 update(getDelegate().withTestOutputDirectory(testOutputDirectory));
112 }
113 }
114
115 @Nonnull
116 public List<Extension> getExtensions() {
117 return new WrapperList<Extension, org.apache.maven.api.model.Extension>(
118 () -> getDelegate().getExtensions(), l -> update(getDelegate().withExtensions(l)),
119 d -> new Extension(d, this), Extension::getDelegate);
120 }
121
122 public void setExtensions(List<Extension> extensions) {
123 if (extensions == null) {
124 extensions = Collections.emptyList();
125 }
126 if (!Objects.equals(extensions, getExtensions())) {
127 update(getDelegate().withExtensions(
128 extensions.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
129 extensions.forEach(e -> e.childrenTracking = this::replace);
130 }
131 }
132
133 public void addExtension(Extension extension) {
134 update(getDelegate().withExtensions(
135 Stream.concat(getDelegate().getExtensions().stream(), Stream.of(extension.getDelegate()))
136 .collect(Collectors.toList())));
137 extension.childrenTracking = this::replace;
138 }
139
140 public void removeExtension(Extension extension) {
141 update(getDelegate().withExtensions(
142 getDelegate().getExtensions().stream()
143 .filter(e -> !Objects.equals(e, extension))
144 .collect(Collectors.toList())));
145 extension.childrenTracking = null;
146 }
147
148 public InputLocation getLocation(Object key) {
149 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
150 return loc != null ? new InputLocation(loc) : null;
151 }
152
153 public void setLocation(Object key, InputLocation location) {
154 update(org.apache.maven.api.model.Build.newBuilder(getDelegate(), true)
155 .location(key, location.toApiLocation()).build());
156 }
157
158 public InputLocation getImportedFrom() {
159 org.apache.maven.api.model.InputLocation loc = getDelegate().getImportedFrom();
160 return loc != null ? new InputLocation(loc) : null;
161 }
162
163 public void setImportedFrom(InputLocation location) {
164 update(org.apache.maven.api.model.Build.newBuilder(getDelegate(), true)
165 .importedFrom(location.toApiLocation()).build());
166 }
167
168 public Set<Object> getLocationKeys() {
169 return getDelegate().getLocationKeys();
170 }
171
172 protected boolean replace(Object oldDelegate, Object newDelegate) {
173 if (super.replace(oldDelegate, newDelegate)) {
174 return true;
175 }
176 if (getDelegate().getExtensions().contains(oldDelegate)) {
177 List<org.apache.maven.api.model.Extension> list = new ArrayList<>(getDelegate().getExtensions());
178 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Extension) newDelegate : d);
179 update(getDelegate().withExtensions(list));
180 return true;
181 }
182 return false;
183 }
184
185 public static List<org.apache.maven.api.model.Build> buildToApiV4(List<Build> list) {
186 return list != null ? new WrapperList<>(list, Build::getDelegate, Build::new) : null;
187 }
188
189 public static List<Build> buildToApiV3(List<org.apache.maven.api.model.Build> list) {
190 return list != null ? new WrapperList<>(list, Build::new, Build::getDelegate) : null;
191 }
192
193
194
195
196
197
198 public String toString()
199 {
200 return "Build {" + super.toString() + "}";
201 }
202
203
204 }