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