1 // =================== DO NOT EDIT THIS FILE ====================
2 // Generated by Modello Velocity from model.vm
3 // template, any modifications will be overwritten.
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 * Repository contains the information needed
21 * for establishing connections with remote repository
22 */
23 @Experimental
24 @Generated @ThreadSafe @Immutable
25 public class RepositoryBase
26 implements Serializable
27 {
28 /**
29 * A unique identifier for a repository.
30 */
31 final String id;
32 /**
33 * Human readable name of the repository.
34 */
35 final String name;
36 /**
37 * The url of the repository.
38 */
39 final String url;
40 /**
41 * The type of layout this repository uses for locating and
42 * storing artifacts - can be "legacy" or "default".
43 */
44 final String layout;
45
46 /**
47 * Constructor for this class, package protected.
48 * @see Builder#build()
49 */
50 RepositoryBase(
51 String id,
52 String name,
53 String url,
54 String layout
55 )
56 {
57 this.id = id;
58 this.name = name;
59 this.url = url;
60 this.layout = layout;
61 }
62
63 @Override
64 public boolean equals( Object o )
65 {
66 if ( this == o )
67 {
68 return true;
69 }
70 if ( o == null || !( o instanceof RepositoryBase ) )
71 {
72 return false;
73 }
74 RepositoryBase that = ( RepositoryBase ) o;
75 return Objects.equals( this.id, that.id );
76 }
77
78 @Override
79 public int hashCode()
80 {
81 return Objects.hash( id );
82 }
83
84 /**
85 * A unique identifier for a repository.
86 *
87 * @return a {@code String}
88 */
89 public String getId()
90 {
91 return this.id;
92 }
93
94 /**
95 * Human readable name of the repository.
96 *
97 * @return a {@code String}
98 */
99 public String getName()
100 {
101 return this.name;
102 }
103
104 /**
105 * The url of the repository.
106 *
107 * @return a {@code String}
108 */
109 public String getUrl()
110 {
111 return this.url;
112 }
113
114 /**
115 * The type of layout this repository uses for locating and
116 * storing artifacts - can be "legacy" or "default".
117 *
118 * @return a {@code String}
119 */
120 public String getLayout()
121 {
122 return this.layout;
123 }
124
125 /**
126 * Creates a new builder with this object as the basis.
127 *
128 * @return a {@code Builder}
129 */
130 @Nonnull
131 public Builder with()
132 {
133 return newBuilder( this );
134 }
135 /**
136 * Creates a new {@code RepositoryBase} instance using the specified id.
137 *
138 * @param id the new {@code String} to use
139 * @return a {@code RepositoryBase} with the specified id
140 */
141 @Nonnull
142 public RepositoryBase withId( String id )
143 {
144 return with().id( id ).build();
145 }
146 /**
147 * Creates a new {@code RepositoryBase} instance using the specified name.
148 *
149 * @param name the new {@code String} to use
150 * @return a {@code RepositoryBase} with the specified name
151 */
152 @Nonnull
153 public RepositoryBase withName( String name )
154 {
155 return with().name( name ).build();
156 }
157 /**
158 * Creates a new {@code RepositoryBase} instance using the specified url.
159 *
160 * @param url the new {@code String} to use
161 * @return a {@code RepositoryBase} with the specified url
162 */
163 @Nonnull
164 public RepositoryBase withUrl( String url )
165 {
166 return with().url( url ).build();
167 }
168 /**
169 * Creates a new {@code RepositoryBase} instance using the specified layout.
170 *
171 * @param layout the new {@code String} to use
172 * @return a {@code RepositoryBase} with the specified layout
173 */
174 @Nonnull
175 public RepositoryBase withLayout( String layout )
176 {
177 return with().layout( layout ).build();
178 }
179
180 /**
181 * Creates a new {@code RepositoryBase} instance.
182 * Equivalent to {@code newInstance( true )}.
183 * @see #newInstance(boolean)
184 *
185 * @return a new {@code RepositoryBase}
186 */
187 @Nonnull
188 public static RepositoryBase newInstance()
189 {
190 return newInstance( true );
191 }
192
193 /**
194 * Creates a new {@code RepositoryBase} instance using default values or not.
195 * Equivalent to {@code newBuilder( withDefaults ).build()}.
196 *
197 * @param withDefaults the boolean indicating whether default values should be used
198 * @return a new {@code RepositoryBase}
199 */
200 @Nonnull
201 public static RepositoryBase newInstance( boolean withDefaults )
202 {
203 return newBuilder( withDefaults ).build();
204 }
205
206 /**
207 * Creates a new {@code RepositoryBase} builder instance.
208 * Equivalent to {@code newBuilder( true )}.
209 * @see #newBuilder(boolean)
210 *
211 * @return a new {@code Builder}
212 */
213 @Nonnull
214 public static Builder newBuilder()
215 {
216 return newBuilder( true );
217 }
218
219 /**
220 * Creates a new {@code RepositoryBase} builder instance using default values or not.
221 *
222 * @param withDefaults the boolean indicating whether default values should be used
223 * @return a new {@code Builder}
224 */
225 @Nonnull
226 public static Builder newBuilder( boolean withDefaults )
227 {
228 return new Builder( withDefaults );
229 }
230
231 /**
232 * Creates a new {@code RepositoryBase} builder instance using the specified object as a basis.
233 * Equivalent to {@code newBuilder( from, false )}.
234 *
235 * @param from the {@code RepositoryBase} instance to use as a basis
236 * @return a new {@code Builder}
237 */
238 @Nonnull
239 public static Builder newBuilder( RepositoryBase from )
240 {
241 return newBuilder( from, false );
242 }
243
244 /**
245 * Creates a new {@code RepositoryBase} builder instance using the specified object as a basis.
246 *
247 * @param from the {@code RepositoryBase} instance to use as a basis
248 * @param forceCopy the boolean indicating if a copy should be forced
249 * @return a new {@code Builder}
250 */
251 @Nonnull
252 public static Builder newBuilder( RepositoryBase from, boolean forceCopy )
253 {
254 return new Builder( from, forceCopy );
255 }
256
257 /**
258 * Builder class used to create RepositoryBase instances.
259 * @see #with()
260 * @see #newBuilder()
261 */
262 @NotThreadSafe
263 public static class Builder
264 {
265 RepositoryBase base;
266 String id;
267 String name;
268 String url;
269 String layout;
270
271 Builder( boolean withDefaults )
272 {
273 if ( withDefaults )
274 {
275 this.layout = "default";
276 }
277 }
278
279 Builder( RepositoryBase base, boolean forceCopy )
280 {
281 if ( forceCopy )
282 {
283 this.id = base.id;
284 this.name = base.name;
285 this.url = base.url;
286 this.layout = base.layout;
287 }
288 else
289 {
290 this.base = base;
291 }
292 }
293
294 @Nonnull
295 public Builder id( String id )
296 {
297 this.id = id;
298 return this;
299 }
300
301 @Nonnull
302 public Builder name( String name )
303 {
304 this.name = name;
305 return this;
306 }
307
308 @Nonnull
309 public Builder url( String url )
310 {
311 this.url = url;
312 return this;
313 }
314
315 @Nonnull
316 public Builder layout( String layout )
317 {
318 this.layout = layout;
319 return this;
320 }
321
322
323 @Nonnull
324 public RepositoryBase build()
325 {
326 if ( base != null
327 && ( id == null || id == base.id )
328 && ( name == null || name == base.name )
329 && ( url == null || url == base.url )
330 && ( layout == null || layout == base.layout )
331 )
332 {
333 return base;
334 }
335 return new RepositoryBase(
336 id != null ? id : ( base != null ? base.id : null ),
337 name != null ? name : ( base != null ? base.name : null ),
338 url != null ? url : ( base != null ? base.url : null ),
339 layout != null ? layout : ( base != null ? base.layout : null )
340 );
341 }
342 }
343
344 }