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 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 Repository
26 extends RepositoryBase
27 implements Serializable
28 {
29
30
31
32 final RepositoryPolicy releases;
33
34
35
36 final RepositoryPolicy snapshots;
37
38
39
40
41
42 Repository(
43 String id,
44 String name,
45 String url,
46 String layout,
47 RepositoryPolicy releases,
48 RepositoryPolicy snapshots
49 )
50 {
51 super(
52 id,
53 name,
54 url,
55 layout
56 );
57 this.releases = releases;
58 this.snapshots = snapshots;
59 }
60
61 @Override
62 public boolean equals( Object o )
63 {
64 if ( this == o )
65 {
66 return true;
67 }
68 if ( o == null || !( o instanceof Repository ) )
69 {
70 return false;
71 }
72 Repository that = ( Repository ) o;
73 return Objects.equals( this.id, that.id );
74 }
75
76 @Override
77 public int hashCode()
78 {
79 return Objects.hash( id );
80 }
81
82
83
84
85
86
87 public RepositoryPolicy getReleases()
88 {
89 return this.releases;
90 }
91
92
93
94
95
96
97 public RepositoryPolicy getSnapshots()
98 {
99 return this.snapshots;
100 }
101
102
103
104
105
106
107 @Nonnull
108 public Builder with()
109 {
110 return newBuilder( this );
111 }
112
113
114
115
116
117
118 @Nonnull
119 public Repository withId( String id )
120 {
121 return with().id( id ).build();
122 }
123
124
125
126
127
128
129 @Nonnull
130 public Repository withName( String name )
131 {
132 return with().name( name ).build();
133 }
134
135
136
137
138
139
140 @Nonnull
141 public Repository withUrl( String url )
142 {
143 return with().url( url ).build();
144 }
145
146
147
148
149
150
151 @Nonnull
152 public Repository withLayout( String layout )
153 {
154 return with().layout( layout ).build();
155 }
156
157
158
159
160
161
162 @Nonnull
163 public Repository withReleases( RepositoryPolicy releases )
164 {
165 return with().releases( releases ).build();
166 }
167
168
169
170
171
172
173 @Nonnull
174 public Repository withSnapshots( RepositoryPolicy snapshots )
175 {
176 return with().snapshots( snapshots ).build();
177 }
178
179
180
181
182
183
184
185
186 @Nonnull
187 public static Repository newInstance()
188 {
189 return newInstance( true );
190 }
191
192
193
194
195
196
197
198
199 @Nonnull
200 public static Repository newInstance( boolean withDefaults )
201 {
202 return newBuilder( withDefaults ).build();
203 }
204
205
206
207
208
209
210
211
212 @Nonnull
213 public static Builder newBuilder()
214 {
215 return newBuilder( true );
216 }
217
218
219
220
221
222
223
224 @Nonnull
225 public static Builder newBuilder( boolean withDefaults )
226 {
227 return new Builder( withDefaults );
228 }
229
230
231
232
233
234
235
236
237 @Nonnull
238 public static Builder newBuilder( Repository from )
239 {
240 return newBuilder( from, false );
241 }
242
243
244
245
246
247
248
249
250 @Nonnull
251 public static Builder newBuilder( Repository from, boolean forceCopy )
252 {
253 return new Builder( from, forceCopy );
254 }
255
256
257
258
259
260
261 @NotThreadSafe
262 public static class Builder
263 extends RepositoryBase.Builder
264 {
265 Repository base;
266 RepositoryPolicy releases;
267 RepositoryPolicy snapshots;
268
269 Builder( boolean withDefaults )
270 {
271 super( withDefaults );
272 if ( withDefaults )
273 {
274 }
275 }
276
277 Builder( Repository base, boolean forceCopy )
278 {
279 super( base, forceCopy );
280 if ( forceCopy )
281 {
282 this.releases = base.releases;
283 this.snapshots = base.snapshots;
284 }
285 else
286 {
287 this.base = base;
288 }
289 }
290
291 @Nonnull
292 public Builder id( String id )
293 {
294 this.id = id;
295 return this;
296 }
297
298 @Nonnull
299 public Builder name( String name )
300 {
301 this.name = name;
302 return this;
303 }
304
305 @Nonnull
306 public Builder url( String url )
307 {
308 this.url = url;
309 return this;
310 }
311
312 @Nonnull
313 public Builder layout( String layout )
314 {
315 this.layout = layout;
316 return this;
317 }
318
319 @Nonnull
320 public Builder releases( RepositoryPolicy releases )
321 {
322 this.releases = releases;
323 return this;
324 }
325
326 @Nonnull
327 public Builder snapshots( RepositoryPolicy snapshots )
328 {
329 this.snapshots = snapshots;
330 return this;
331 }
332
333
334 @Nonnull
335 public Repository build()
336 {
337 if ( base != null
338 && ( id == null || id == base.id )
339 && ( name == null || name == base.name )
340 && ( url == null || url == base.url )
341 && ( layout == null || layout == base.layout )
342 && ( releases == null || releases == base.releases )
343 && ( snapshots == null || snapshots == base.snapshots )
344 )
345 {
346 return base;
347 }
348 return new Repository(
349 id != null ? id : ( base != null ? base.id : null ),
350 name != null ? name : ( base != null ? base.name : null ),
351 url != null ? url : ( base != null ? base.url : null ),
352 layout != null ? layout : ( base != null ? base.layout : null ),
353 releases != null ? releases : ( base != null ? base.releases : null ),
354 snapshots != null ? snapshots : ( base != null ? base.snapshots : null )
355 );
356 }
357 }
358
359 }