1
2
3
4
5 package org.apache.maven.api.model;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import org.apache.maven.api.annotations.Experimental;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Immutable;
17 import org.apache.maven.api.annotations.Nonnull;
18 import org.apache.maven.api.annotations.NotThreadSafe;
19 import org.apache.maven.api.annotations.ThreadSafe;
20
21
22
23
24
25 @Experimental
26 @Generated @ThreadSafe @Immutable
27 public class CiManagement
28 implements Serializable, InputLocationTracker
29 {
30
31
32
33 final String system;
34
35
36
37
38 final String url;
39
40
41
42
43 final List<Notifier> notifiers;
44
45 final Map<Object, InputLocation> locations;
46
47
48
49
50
51 CiManagement(
52 String system,
53 String url,
54 Collection<Notifier> notifiers,
55 Map<Object, InputLocation> locations
56 ) {
57 this.system = system;
58 this.url = url;
59 this.notifiers = ImmutableCollections.copy(notifiers);
60 this.locations = ImmutableCollections.copy(locations);
61 }
62
63
64
65
66
67
68 public String getSystem() {
69 return this.system;
70 }
71
72
73
74
75
76
77
78 public String getUrl() {
79 return this.url;
80 }
81
82
83
84
85
86
87
88 @Nonnull
89 public List<Notifier> getNotifiers() {
90 return this.notifiers;
91 }
92
93
94
95
96 public InputLocation getLocation(Object key) {
97 return locations != null ? locations.get(key) : null;
98 }
99
100
101
102
103
104
105 @Nonnull
106 public Builder with() {
107 return newBuilder(this);
108 }
109
110
111
112
113
114
115 @Nonnull
116 public CiManagement withSystem(String system) {
117 return newBuilder(this, true).system(system).build();
118 }
119
120
121
122
123
124
125 @Nonnull
126 public CiManagement withUrl(String url) {
127 return newBuilder(this, true).url(url).build();
128 }
129
130
131
132
133
134
135 @Nonnull
136 public CiManagement withNotifiers(Collection<Notifier> notifiers) {
137 return newBuilder(this, true).notifiers(notifiers).build();
138 }
139
140
141
142
143
144
145
146
147 @Nonnull
148 public static CiManagement newInstance() {
149 return newInstance(true);
150 }
151
152
153
154
155
156
157
158
159 @Nonnull
160 public static CiManagement newInstance(boolean withDefaults) {
161 return newBuilder(withDefaults).build();
162 }
163
164
165
166
167
168
169
170
171 @Nonnull
172 public static Builder newBuilder() {
173 return newBuilder(true);
174 }
175
176
177
178
179
180
181
182 @Nonnull
183 public static Builder newBuilder(boolean withDefaults) {
184 return new Builder(withDefaults);
185 }
186
187
188
189
190
191
192
193
194 @Nonnull
195 public static Builder newBuilder(CiManagement from) {
196 return newBuilder(from, false);
197 }
198
199
200
201
202
203
204
205
206 @Nonnull
207 public static Builder newBuilder(CiManagement from, boolean forceCopy) {
208 return new Builder(from, forceCopy);
209 }
210
211
212
213
214
215
216 @NotThreadSafe
217 public static class Builder
218 {
219 CiManagement base;
220 String system;
221 String url;
222 Collection<Notifier> notifiers;
223 Map<Object, InputLocation> locations;
224
225 Builder(boolean withDefaults) {
226 if (withDefaults) {
227 }
228 }
229
230 Builder(CiManagement base, boolean forceCopy) {
231 if (forceCopy) {
232 this.system = base.system;
233 this.url = base.url;
234 this.notifiers = base.notifiers;
235 this.locations = base.locations;
236 } else {
237 this.base = base;
238 }
239 }
240
241 @Nonnull
242 public Builder system(String system) {
243 this.system = system;
244 return this;
245 }
246
247 @Nonnull
248 public Builder url(String url) {
249 this.url = url;
250 return this;
251 }
252
253 @Nonnull
254 public Builder notifiers(Collection<Notifier> notifiers) {
255 this.notifiers = notifiers;
256 return this;
257 }
258
259
260 @Nonnull
261 public Builder location(Object key, InputLocation location) {
262 if (location != null) {
263 if (!(this.locations instanceof HashMap)) {
264 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
265 }
266 this.locations.put(key, location);
267 }
268 return this;
269 }
270
271 @Nonnull
272 public CiManagement build() {
273 if (base != null
274 && (system == null || system == base.system)
275 && (url == null || url == base.url)
276 && (notifiers == null || notifiers == base.notifiers)
277 ) {
278 return base;
279 }
280 Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
281 Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
282 Map<Object, InputLocation> locations = new HashMap<>();
283 locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
284 locations.put("system", newlocs.containsKey("system") ? newlocs.get("system") : oldlocs.get("system"));
285 locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
286 locations.put("notifiers", newlocs.containsKey("notifiers") ? newlocs.get("notifiers") : oldlocs.get("notifiers"));
287 return new CiManagement(
288 system != null ? system : (base != null ? base.system : null),
289 url != null ? url : (base != null ? base.url : null),
290 notifiers != null ? notifiers : (base != null ? base.notifiers : null),
291 locations
292 );
293 }
294 }
295
296 }