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