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