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 for establishing
19   * connections with remote repository
20   */
21  @Experimental
22  @Generated @ThreadSafe @Immutable
23  public class Repository
24      extends RepositoryBase
25      implements Serializable
26  {
27      /**
28       * How to handle downloading of releases from this repository
29       */
30      final RepositoryPolicy releases;
31      /**
32       * How to handle downloading of snapshots from this repository
33       */
34      final RepositoryPolicy snapshots;
35  
36      /**
37        * Constructor for this class, package protected.
38        * @see Builder#build()
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       * How to handle downloading of releases from this repository
61       *
62       * @return a {@code RepositoryPolicy}
63       */
64      public RepositoryPolicy getReleases()
65      {
66          return this.releases;
67      }
68  
69      /**
70       * How to handle downloading of snapshots from this repository
71       *
72       * @return a {@code RepositoryPolicy}
73       */
74      public RepositoryPolicy getSnapshots()
75      {
76          return this.snapshots;
77      }
78  
79      /**
80       * Creates a new builder with this object as the basis.
81       *
82       * @return a {@code Builder}
83       */
84      @Nonnull
85      public Builder with()
86      {
87          return newBuilder( this );
88      }
89      /**
90       * Creates a new {@code Repository} instance using the specified id.
91       *
92       * @param id the new {@code String} to use
93       * @return a {@code Repository} with the specified id
94       */
95      @Nonnull
96      public Repository withId( String id )
97      {
98          return with().id( id ).build();
99      }
100     /**
101      * Creates a new {@code Repository} instance using the specified name.
102      *
103      * @param name the new {@code String} to use
104      * @return a {@code Repository} with the specified name
105      */
106     @Nonnull
107     public Repository withName( String name )
108     {
109         return with().name( name ).build();
110     }
111     /**
112      * Creates a new {@code Repository} instance using the specified url.
113      *
114      * @param url the new {@code String} to use
115      * @return a {@code Repository} with the specified url
116      */
117     @Nonnull
118     public Repository withUrl( String url )
119     {
120         return with().url( url ).build();
121     }
122     /**
123      * Creates a new {@code Repository} instance using the specified layout.
124      *
125      * @param layout the new {@code String} to use
126      * @return a {@code Repository} with the specified layout
127      */
128     @Nonnull
129     public Repository withLayout( String layout )
130     {
131         return with().layout( layout ).build();
132     }
133     /**
134      * Creates a new {@code Repository} instance using the specified releases.
135      *
136      * @param releases the new {@code RepositoryPolicy} to use
137      * @return a {@code Repository} with the specified releases
138      */
139     @Nonnull
140     public Repository withReleases( RepositoryPolicy releases )
141     {
142         return with().releases( releases ).build();
143     }
144     /**
145      * Creates a new {@code Repository} instance using the specified snapshots.
146      *
147      * @param snapshots the new {@code RepositoryPolicy} to use
148      * @return a {@code Repository} with the specified snapshots
149      */
150     @Nonnull
151     public Repository withSnapshots( RepositoryPolicy snapshots )
152     {
153         return with().snapshots( snapshots ).build();
154     }
155 
156     /**
157      * Creates a new {@code Repository} instance.
158      * Equivalent to {@code newInstance( true )}.
159      * @see #newInstance(boolean)
160      *
161      * @return a new {@code Repository}
162      */
163     @Nonnull
164     public static Repository newInstance()
165     {
166         return newInstance( true );
167     }
168 
169     /**
170      * Creates a new {@code Repository} instance using default values or not.
171      * Equivalent to {@code newBuilder( withDefaults ).build()}.
172      *
173      * @param withDefaults the boolean indicating whether default values should be used
174      * @return a new {@code Repository}
175      */
176     @Nonnull
177     public static Repository newInstance( boolean withDefaults )
178     {
179         return newBuilder( withDefaults ).build();
180     }
181 
182     /**
183      * Creates a new {@code Repository} builder instance.
184      * Equivalent to {@code newBuilder( true )}.
185      * @see #newBuilder(boolean)
186      *
187      * @return a new {@code Builder}
188      */
189     @Nonnull
190     public static Builder newBuilder()
191     {
192         return newBuilder( true );
193     }
194 
195     /**
196      * Creates a new {@code Repository} builder instance using default values or not.
197      *
198      * @param withDefaults the boolean indicating whether default values should be used
199      * @return a new {@code Builder}
200      */
201     @Nonnull
202     public static Builder newBuilder( boolean withDefaults )
203     {
204         return new Builder( withDefaults );
205     }
206 
207     /**
208      * Creates a new {@code Repository} builder instance using the specified object as a basis.
209      * Equivalent to {@code newBuilder( from, false )}.
210      *
211      * @param from the {@code Repository} instance to use as a basis
212      * @return a new {@code Builder}
213      */
214     @Nonnull
215     public static Builder newBuilder( Repository from )
216     {
217         return newBuilder( from, false );
218     }
219 
220     /**
221      * Creates a new {@code Repository} builder instance using the specified object as a basis.
222      *
223      * @param from the {@code Repository} instance to use as a basis
224      * @param forceCopy the boolean indicating if a copy should be forced
225      * @return a new {@code Builder}
226      */
227     @Nonnull
228     public static Builder newBuilder( Repository from, boolean forceCopy )
229     {
230         return new Builder( from, forceCopy );
231     }
232 
233     /**
234      * Builder class used to create Repository instances.
235      * @see #with()
236      * @see #newBuilder()
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      * @see RepositoryBase#equals(java.lang.Object)
340      */
341     public boolean equals( Object obj )
342     {
343         return super.equals( obj );
344     }
345             
346           
347 }