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