1
2
3
4
5 package org.apache.maven.api.settings;
6
7 import java.io.Serializable;
8 import java.util.Collections;
9 import java.util.HashMap;
10 import java.util.Map;
11 import org.apache.maven.api.annotations.Experimental;
12 import org.apache.maven.api.annotations.Generated;
13 import org.apache.maven.api.annotations.Immutable;
14 import org.apache.maven.api.annotations.Nonnull;
15 import org.apache.maven.api.annotations.NotThreadSafe;
16 import org.apache.maven.api.annotations.ThreadSafe;
17
18
19
20
21 @Experimental
22 @Generated @ThreadSafe @Immutable
23 public class Mirror
24 extends IdentifiableBase
25 implements Serializable, InputLocationTracker
26 {
27
28
29
30
31
32
33 final String mirrorOf;
34
35
36
37 final String name;
38
39
40
41 final String url;
42
43
44
45
46 final String layout;
47
48
49
50
51
52 final String mirrorOfLayouts;
53
54
55
56
57
58 final boolean blocked;
59
60
61
62
63
64 Mirror(
65 String id,
66 String mirrorOf,
67 String name,
68 String url,
69 String layout,
70 String mirrorOfLayouts,
71 boolean blocked,
72 Map<Object, InputLocation> locations
73 ) {
74 super(
75 id,
76 locations
77 );
78 this.mirrorOf = mirrorOf;
79 this.name = name;
80 this.url = url;
81 this.layout = layout;
82 this.mirrorOfLayouts = mirrorOfLayouts;
83 this.blocked = blocked;
84 }
85
86
87
88
89
90
91
92
93
94 public String getMirrorOf() {
95 return this.mirrorOf;
96 }
97
98
99
100
101
102
103 public String getName() {
104 return this.name;
105 }
106
107
108
109
110
111
112 public String getUrl() {
113 return this.url;
114 }
115
116
117
118
119
120
121
122 public String getLayout() {
123 return this.layout;
124 }
125
126
127
128
129
130
131
132
133 public String getMirrorOfLayouts() {
134 return this.mirrorOfLayouts;
135 }
136
137
138
139
140
141
142
143
144 public boolean isBlocked() {
145 return this.blocked;
146 }
147
148
149
150
151
152
153 @Nonnull
154 public Builder with() {
155 return newBuilder(this);
156 }
157
158
159
160
161
162
163 @Nonnull
164 public Mirror withId(String id) {
165 return newBuilder(this, true).id(id).build();
166 }
167
168
169
170
171
172
173 @Nonnull
174 public Mirror withMirrorOf(String mirrorOf) {
175 return newBuilder(this, true).mirrorOf(mirrorOf).build();
176 }
177
178
179
180
181
182
183 @Nonnull
184 public Mirror withName(String name) {
185 return newBuilder(this, true).name(name).build();
186 }
187
188
189
190
191
192
193 @Nonnull
194 public Mirror withUrl(String url) {
195 return newBuilder(this, true).url(url).build();
196 }
197
198
199
200
201
202
203 @Nonnull
204 public Mirror withLayout(String layout) {
205 return newBuilder(this, true).layout(layout).build();
206 }
207
208
209
210
211
212
213 @Nonnull
214 public Mirror withMirrorOfLayouts(String mirrorOfLayouts) {
215 return newBuilder(this, true).mirrorOfLayouts(mirrorOfLayouts).build();
216 }
217
218
219
220
221
222
223 @Nonnull
224 public Mirror withBlocked(boolean blocked) {
225 return newBuilder(this, true).blocked(blocked).build();
226 }
227
228
229
230
231
232
233
234
235 @Nonnull
236 public static Mirror newInstance() {
237 return newInstance(true);
238 }
239
240
241
242
243
244
245
246
247 @Nonnull
248 public static Mirror newInstance(boolean withDefaults) {
249 return newBuilder(withDefaults).build();
250 }
251
252
253
254
255
256
257
258
259 @Nonnull
260 public static Builder newBuilder() {
261 return newBuilder(true);
262 }
263
264
265
266
267
268
269
270 @Nonnull
271 public static Builder newBuilder(boolean withDefaults) {
272 return new Builder(withDefaults);
273 }
274
275
276
277
278
279
280
281
282 @Nonnull
283 public static Builder newBuilder(Mirror from) {
284 return newBuilder(from, false);
285 }
286
287
288
289
290
291
292
293
294 @Nonnull
295 public static Builder newBuilder(Mirror from, boolean forceCopy) {
296 return new Builder(from, forceCopy);
297 }
298
299
300
301
302
303
304 @NotThreadSafe
305 public static class Builder
306 extends IdentifiableBase.Builder
307 {
308 Mirror base;
309 String mirrorOf;
310 String name;
311 String url;
312 String layout;
313 String mirrorOfLayouts;
314 Boolean blocked;
315
316 Builder(boolean withDefaults) {
317 super(withDefaults);
318 if (withDefaults) {
319 this.layout = "default";
320 this.mirrorOfLayouts = "default,legacy";
321 this.blocked = false;
322 }
323 }
324
325 Builder(Mirror base, boolean forceCopy) {
326 super(base, forceCopy);
327 if (forceCopy) {
328 this.mirrorOf = base.mirrorOf;
329 this.name = base.name;
330 this.url = base.url;
331 this.layout = base.layout;
332 this.mirrorOfLayouts = base.mirrorOfLayouts;
333 this.blocked = base.blocked;
334 this.locations = base.locations;
335 } else {
336 this.base = base;
337 }
338 }
339
340 @Nonnull
341 public Builder id(String id) {
342 this.id = id;
343 return this;
344 }
345
346 @Nonnull
347 public Builder mirrorOf(String mirrorOf) {
348 this.mirrorOf = mirrorOf;
349 return this;
350 }
351
352 @Nonnull
353 public Builder name(String name) {
354 this.name = name;
355 return this;
356 }
357
358 @Nonnull
359 public Builder url(String url) {
360 this.url = url;
361 return this;
362 }
363
364 @Nonnull
365 public Builder layout(String layout) {
366 this.layout = layout;
367 return this;
368 }
369
370 @Nonnull
371 public Builder mirrorOfLayouts(String mirrorOfLayouts) {
372 this.mirrorOfLayouts = mirrorOfLayouts;
373 return this;
374 }
375
376 @Nonnull
377 public Builder blocked(boolean blocked) {
378 this.blocked = blocked;
379 return this;
380 }
381
382
383 @Nonnull
384 public Builder location(Object key, InputLocation location) {
385 if (location != null) {
386 if (!(this.locations instanceof HashMap)) {
387 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
388 }
389 this.locations.put(key, location);
390 }
391 return this;
392 }
393
394 @Nonnull
395 public Mirror build() {
396 if (base != null
397 && (id == null || id == base.id)
398 && (mirrorOf == null || mirrorOf == base.mirrorOf)
399 && (name == null || name == base.name)
400 && (url == null || url == base.url)
401 && (layout == null || layout == base.layout)
402 && (mirrorOfLayouts == null || mirrorOfLayouts == base.mirrorOfLayouts)
403 && (blocked == null || blocked == base.blocked)
404 ) {
405 return base;
406 }
407 Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
408 Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
409 Map<Object, InputLocation> locations = new HashMap<>();
410 locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
411 locations.put("id", newlocs.containsKey("id") ? newlocs.get("id") : oldlocs.get("id"));
412 locations.put("mirrorOf", newlocs.containsKey("mirrorOf") ? newlocs.get("mirrorOf") : oldlocs.get("mirrorOf"));
413 locations.put("name", newlocs.containsKey("name") ? newlocs.get("name") : oldlocs.get("name"));
414 locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
415 locations.put("layout", newlocs.containsKey("layout") ? newlocs.get("layout") : oldlocs.get("layout"));
416 locations.put("mirrorOfLayouts", newlocs.containsKey("mirrorOfLayouts") ? newlocs.get("mirrorOfLayouts") : oldlocs.get("mirrorOfLayouts"));
417 locations.put("blocked", newlocs.containsKey("blocked") ? newlocs.get("blocked") : oldlocs.get("blocked"));
418 return new Mirror(
419 id != null ? id : (base != null ? base.id : null),
420 mirrorOf != null ? mirrorOf : (base != null ? base.mirrorOf : null),
421 name != null ? name : (base != null ? base.name : null),
422 url != null ? url : (base != null ? base.url : null),
423 layout != null ? layout : (base != null ? base.layout : null),
424 mirrorOfLayouts != null ? mirrorOfLayouts : (base != null ? base.mirrorOfLayouts : null),
425 blocked != null ? blocked : (base != null ? base.blocked : false),
426 locations
427 );
428 }
429 }
430
431
432
433
434 public String toString() {
435 StringBuilder sb = new StringBuilder(128);
436 sb.append("Mirror[");
437 sb.append("id=").append(this.getId());
438 sb.append(",mirrorOf=").append(this.getMirrorOf());
439 sb.append(",url=").append(this.getUrl());
440 sb.append(",name=").append(this.getName());
441 if (isBlocked()) {
442 sb.append(",blocked");
443 }
444 sb.append("]");
445 return sb.toString();
446 }
447
448
449 }