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   * A download mirror for a given repository.
19   */
20  @Experimental
21  @Generated @ThreadSafe @Immutable
22  public class Mirror
23      extends IdentifiableBase
24      implements Serializable
25  {
26      /**
27       * The server ID of the repository being mirrored, e.g.,
28       * "central". This MUST NOT match the mirror id.
29       */
30      final String mirrorOf;
31      /**
32       * The optional name that describes the mirror.
33       */
34      final String name;
35      /**
36       * The URL of the mirror repository.
37       */
38      final String url;
39      /**
40       * The layout of the mirror repository. Since Maven 3.
41       */
42      final String layout;
43      /**
44       * The layouts of repositories being mirrored. This value can be used to restrict the usage
45       * of the mirror to repositories with a matching layout (apart from a matching id). Since Maven 3.
46       */
47      final String mirrorOfLayouts;
48      /**
49       * Whether this mirror should be blocked from any download request but fail the download process, explaining why.
50       */
51      final boolean blocked;
52  
53      /**
54        * Constructor for this class, package protected.
55        * @see Builder#build()
56        */
57      Mirror(
58          String id,
59          String mirrorOf,
60          String name,
61          String url,
62          String layout,
63          String mirrorOfLayouts,
64          boolean blocked
65      )
66      {
67          super(
68              id
69          );
70          this.mirrorOf = mirrorOf;
71          this.name = name;
72          this.url = url;
73          this.layout = layout;
74          this.mirrorOfLayouts = mirrorOfLayouts;
75          this.blocked = blocked;
76      }
77  
78      /**
79       * The server ID of the repository being mirrored, e.g.,
80       * "central". This MUST NOT match the mirror id.
81       *
82       * @return a {@code String}
83       */
84      public String getMirrorOf()
85      {
86          return this.mirrorOf;
87      }
88  
89      /**
90       * The optional name that describes the mirror.
91       *
92       * @return a {@code String}
93       */
94      public String getName()
95      {
96          return this.name;
97      }
98  
99      /**
100      * The URL of the mirror repository.
101      *
102      * @return a {@code String}
103      */
104     public String getUrl()
105     {
106         return this.url;
107     }
108 
109     /**
110      * The layout of the mirror repository. Since Maven 3.
111      *
112      * @return a {@code String}
113      */
114     public String getLayout()
115     {
116         return this.layout;
117     }
118 
119     /**
120      * The layouts of repositories being mirrored. This value can be used to restrict the usage
121      * of the mirror to repositories with a matching layout (apart from a matching id). Since Maven 3.
122      *
123      * @return a {@code String}
124      */
125     public String getMirrorOfLayouts()
126     {
127         return this.mirrorOfLayouts;
128     }
129 
130     /**
131      * Whether this mirror should be blocked from any download request but fail the download process, explaining why.
132      *
133      * @return a {@code boolean}
134      */
135     public boolean isBlocked()
136     {
137         return this.blocked;
138     }
139 
140     /**
141      * Creates a new builder with this object as the basis.
142      *
143      * @return a {@code Builder}
144      */
145     @Nonnull
146     public Builder with()
147     {
148         return newBuilder( this );
149     }
150     /**
151      * Creates a new {@code Mirror} instance using the specified id.
152      *
153      * @param id the new {@code String} to use
154      * @return a {@code Mirror} with the specified id
155      */
156     @Nonnull
157     public Mirror withId( String id )
158     {
159         return with().id( id ).build();
160     }
161     /**
162      * Creates a new {@code Mirror} instance using the specified mirrorOf.
163      *
164      * @param mirrorOf the new {@code String} to use
165      * @return a {@code Mirror} with the specified mirrorOf
166      */
167     @Nonnull
168     public Mirror withMirrorOf( String mirrorOf )
169     {
170         return with().mirrorOf( mirrorOf ).build();
171     }
172     /**
173      * Creates a new {@code Mirror} instance using the specified name.
174      *
175      * @param name the new {@code String} to use
176      * @return a {@code Mirror} with the specified name
177      */
178     @Nonnull
179     public Mirror withName( String name )
180     {
181         return with().name( name ).build();
182     }
183     /**
184      * Creates a new {@code Mirror} instance using the specified url.
185      *
186      * @param url the new {@code String} to use
187      * @return a {@code Mirror} with the specified url
188      */
189     @Nonnull
190     public Mirror withUrl( String url )
191     {
192         return with().url( url ).build();
193     }
194     /**
195      * Creates a new {@code Mirror} instance using the specified layout.
196      *
197      * @param layout the new {@code String} to use
198      * @return a {@code Mirror} with the specified layout
199      */
200     @Nonnull
201     public Mirror withLayout( String layout )
202     {
203         return with().layout( layout ).build();
204     }
205     /**
206      * Creates a new {@code Mirror} instance using the specified mirrorOfLayouts.
207      *
208      * @param mirrorOfLayouts the new {@code String} to use
209      * @return a {@code Mirror} with the specified mirrorOfLayouts
210      */
211     @Nonnull
212     public Mirror withMirrorOfLayouts( String mirrorOfLayouts )
213     {
214         return with().mirrorOfLayouts( mirrorOfLayouts ).build();
215     }
216     /**
217      * Creates a new {@code Mirror} instance using the specified blocked.
218      *
219      * @param blocked the new {@code boolean} to use
220      * @return a {@code Mirror} with the specified blocked
221      */
222     @Nonnull
223     public Mirror withBlocked( boolean blocked )
224     {
225         return with().blocked( blocked ).build();
226     }
227 
228     /**
229      * Creates a new {@code Mirror} instance.
230      * Equivalent to {@code newInstance( true )}.
231      * @see #newInstance(boolean)
232      *
233      * @return a new {@code Mirror}
234      */
235     @Nonnull
236     public static Mirror newInstance()
237     {
238         return newInstance( true );
239     }
240 
241     /**
242      * Creates a new {@code Mirror} instance using default values or not.
243      * Equivalent to {@code newBuilder( withDefaults ).build()}.
244      *
245      * @param withDefaults the boolean indicating whether default values should be used
246      * @return a new {@code Mirror}
247      */
248     @Nonnull
249     public static Mirror newInstance( boolean withDefaults )
250     {
251         return newBuilder( withDefaults ).build();
252     }
253 
254     /**
255      * Creates a new {@code Mirror} builder instance.
256      * Equivalent to {@code newBuilder( true )}.
257      * @see #newBuilder(boolean)
258      *
259      * @return a new {@code Builder}
260      */
261     @Nonnull
262     public static Builder newBuilder()
263     {
264         return newBuilder( true );
265     }
266 
267     /**
268      * Creates a new {@code Mirror} builder instance using default values or not.
269      *
270      * @param withDefaults the boolean indicating whether default values should be used
271      * @return a new {@code Builder}
272      */
273     @Nonnull
274     public static Builder newBuilder( boolean withDefaults )
275     {
276         return new Builder( withDefaults );
277     }
278 
279     /**
280      * Creates a new {@code Mirror} builder instance using the specified object as a basis.
281      * Equivalent to {@code newBuilder( from, false )}.
282      *
283      * @param from the {@code Mirror} instance to use as a basis
284      * @return a new {@code Builder}
285      */
286     @Nonnull
287     public static Builder newBuilder( Mirror from )
288     {
289         return newBuilder( from, false );
290     }
291 
292     /**
293      * Creates a new {@code Mirror} builder instance using the specified object as a basis.
294      *
295      * @param from the {@code Mirror} instance to use as a basis
296      * @param forceCopy the boolean indicating if a copy should be forced
297      * @return a new {@code Builder}
298      */
299     @Nonnull
300     public static Builder newBuilder( Mirror from, boolean forceCopy )
301     {
302         return new Builder( from, forceCopy );
303     }
304 
305     /**
306      * Builder class used to create Mirror instances.
307      * @see #with()
308      * @see #newBuilder()
309      */
310     @NotThreadSafe
311     public static class Builder
312         extends IdentifiableBase.Builder
313     {
314         Mirror base;
315         String mirrorOf;
316         String name;
317         String url;
318         String layout;
319         String mirrorOfLayouts;
320         Boolean blocked;
321 
322         Builder( boolean withDefaults )
323         {
324             super( withDefaults );
325             if ( withDefaults )
326             {
327                 this.layout = "default";
328                 this.mirrorOfLayouts = "default,legacy";
329                 this.blocked = false;
330             }
331         }
332 
333         Builder( Mirror base, boolean forceCopy )
334         {
335             super( base, forceCopy );
336             if ( forceCopy )
337             {
338                 this.mirrorOf = base.mirrorOf;
339                 this.name = base.name;
340                 this.url = base.url;
341                 this.layout = base.layout;
342                 this.mirrorOfLayouts = base.mirrorOfLayouts;
343                 this.blocked = base.blocked;
344             }
345             else
346             {
347                 this.base = base;
348             }
349         }
350 
351         @Nonnull
352         public Builder id( String id )
353         {
354             this.id = id;
355             return this;
356         }
357 
358         @Nonnull
359         public Builder mirrorOf( String mirrorOf )
360         {
361             this.mirrorOf = mirrorOf;
362             return this;
363         }
364 
365         @Nonnull
366         public Builder name( String name )
367         {
368             this.name = name;
369             return this;
370         }
371 
372         @Nonnull
373         public Builder url( String url )
374         {
375             this.url = url;
376             return this;
377         }
378 
379         @Nonnull
380         public Builder layout( String layout )
381         {
382             this.layout = layout;
383             return this;
384         }
385 
386         @Nonnull
387         public Builder mirrorOfLayouts( String mirrorOfLayouts )
388         {
389             this.mirrorOfLayouts = mirrorOfLayouts;
390             return this;
391         }
392 
393         @Nonnull
394         public Builder blocked( boolean blocked )
395         {
396             this.blocked = blocked;
397             return this;
398         }
399 
400 
401         @Nonnull
402         public Mirror build()
403         {
404             if ( base != null
405                     && ( id == null || id == base.id )
406                     && ( mirrorOf == null || mirrorOf == base.mirrorOf )
407                     && ( name == null || name == base.name )
408                     && ( url == null || url == base.url )
409                     && ( layout == null || layout == base.layout )
410                     && ( mirrorOfLayouts == null || mirrorOfLayouts == base.mirrorOfLayouts )
411                     && ( blocked == null || blocked == base.blocked )
412             )
413             {
414                 return base;
415             }
416             return new Mirror(
417                 id != null ? id : ( base != null ? base.id : null ),
418                 mirrorOf != null ? mirrorOf : ( base != null ? base.mirrorOf : null ),
419                 name != null ? name : ( base != null ? base.name : null ),
420                 url != null ? url : ( base != null ? base.url : null ),
421                 layout != null ? layout : ( base != null ? base.layout : null ),
422                 mirrorOfLayouts != null ? mirrorOfLayouts : ( base != null ? base.mirrorOfLayouts : null ),
423                 blocked != null ? blocked : ( base != null ? base.blocked : false )
424             );
425         }
426     }
427 
428 
429             
430 
431     public String toString()
432     {
433         StringBuilder sb = new StringBuilder( 128 );
434         sb.append( "Mirror[" );
435         sb.append( "id=" ).append( this.getId() );
436         sb.append( ",mirrorOf=" ).append( this.getMirrorOf() );
437         sb.append( ",url=" ).append( this.getUrl() );
438         sb.append( ",name=" ).append( this.getName() );
439         if ( isBlocked() )
440         {
441             sb.append( ",blocked" );
442         }
443         sb.append( "]" );
444         return sb.toString();
445     }
446             
447           
448 }