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