View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //   Generated by Maven, any modifications will be overwritten.
3   // ==============================================================
4   package org.apache.maven.api.model;
5   
6   import java.io.Serializable;
7   import java.util.ArrayList;
8   import java.util.Collection;
9   import java.util.Collections;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
13  import org.apache.maven.api.annotations.Experimental;
14  import org.apache.maven.api.annotations.Generated;
15  import org.apache.maven.api.annotations.Immutable;
16  import org.apache.maven.api.annotations.Nonnull;
17  import org.apache.maven.api.annotations.NotThreadSafe;
18  import org.apache.maven.api.annotations.ThreadSafe;
19  
20  /**
21   * The {@code <ciManagement>} element contains informations required to the
22   * continuous integration system of the project.
23   */
24  @Experimental
25  @Generated @ThreadSafe @Immutable
26  public class CiManagement
27      implements Serializable, InputLocationTracker
28  {
29      /**
30       * The name of the continuous integration system, e.g. {@code continuum}.
31       */
32      final String system;
33      /**
34       * URL for the continuous integration system used by the project if it has a web
35       * interface.
36       */
37      final String url;
38      /**
39       * Configuration for notifying developers/users when a build is unsuccessful,
40       * including user information and notification mode.
41       */
42      final List<Notifier> notifiers;
43      /** Location of the xml element for this object. */
44      final InputLocation location;
45      /** Location of the xml element for the field system. */
46      final InputLocation systemLocation;
47      /** Location of the xml element for the field url. */
48      final InputLocation urlLocation;
49      /** Location of the xml element for the field notifiers. */
50      final InputLocation notifiersLocation;
51      /** Other locations */
52      final Map<Object, InputLocation> locations;
53  
54      /**
55        * Constructor for this class, package protected.
56        * @see Builder#build()
57        */
58      CiManagement(
59          String system,
60          String url,
61          Collection<Notifier> notifiers,
62          Map<Object, InputLocation> locations,
63          InputLocation location,
64          InputLocation systemLocation,
65          InputLocation urlLocation,
66          InputLocation notifiersLocation
67      )
68      {
69          this.system = system;
70          this.url = url;
71          this.notifiers = ImmutableCollections.copy( notifiers );
72          this.locations = ImmutableCollections.copy( locations );
73          this.location = location;
74          this.systemLocation = systemLocation;
75          this.urlLocation = urlLocation;
76          this.notifiersLocation = notifiersLocation;
77      }
78  
79      /**
80       * The name of the continuous integration system, e.g. {@code continuum}.
81       *
82       * @return a {@code String}
83       */
84      public String getSystem()
85      {
86          return this.system;
87      }
88  
89      /**
90       * URL for the continuous integration system used by the project if it has a web
91       * interface.
92       *
93       * @return a {@code String}
94       */
95      public String getUrl()
96      {
97          return this.url;
98      }
99  
100     /**
101      * Configuration for notifying developers/users when a build is unsuccessful,
102      * including user information and notification mode.
103      *
104      * @return a {@code List<Notifier>}
105      */
106     @Nonnull
107     public List<Notifier> getNotifiers()
108     {
109         return this.notifiers;
110     }
111 
112     /**
113      * Gets the location of the specified field in the input source.
114      */
115     public InputLocation getLocation( Object key )
116     {
117         if ( key instanceof String )
118         {
119             switch ( ( String ) key )
120             {
121                 case "":
122                     return location;
123                 case "system":
124                     return systemLocation;
125                 case "url":
126                     return urlLocation;
127                 case "notifiers":
128                     return notifiersLocation;
129             }
130         }
131         return locations != null ? locations.get( key ) : null;
132     }
133 
134     /**
135      * Creates a new builder with this object as the basis.
136      *
137      * @return a {@code Builder}
138      */
139     @Nonnull
140     public Builder with()
141     {
142         return newBuilder( this );
143     }
144     /**
145      * Creates a new {@code CiManagement} instance using the specified system.
146      *
147      * @param system the new {@code String} to use
148      * @return a {@code CiManagement} with the specified system
149      */
150     @Nonnull
151     public CiManagement withSystem( String system )
152     {
153         return with().system( system ).build();
154     }
155     /**
156      * Creates a new {@code CiManagement} instance using the specified url.
157      *
158      * @param url the new {@code String} to use
159      * @return a {@code CiManagement} with the specified url
160      */
161     @Nonnull
162     public CiManagement withUrl( String url )
163     {
164         return with().url( url ).build();
165     }
166     /**
167      * Creates a new {@code CiManagement} instance using the specified notifiers.
168      *
169      * @param notifiers the new {@code Collection<Notifier>} to use
170      * @return a {@code CiManagement} with the specified notifiers
171      */
172     @Nonnull
173     public CiManagement withNotifiers( Collection<Notifier> notifiers )
174     {
175         return with().notifiers( notifiers ).build();
176     }
177 
178     /**
179      * Creates a new {@code CiManagement} instance.
180      * Equivalent to {@code newInstance( true )}.
181      * @see #newInstance(boolean)
182      *
183      * @return a new {@code CiManagement}
184      */
185     @Nonnull
186     public static CiManagement newInstance()
187     {
188         return newInstance( true );
189     }
190 
191     /**
192      * Creates a new {@code CiManagement} instance using default values or not.
193      * Equivalent to {@code newBuilder( withDefaults ).build()}.
194      *
195      * @param withDefaults the boolean indicating whether default values should be used
196      * @return a new {@code CiManagement}
197      */
198     @Nonnull
199     public static CiManagement newInstance( boolean withDefaults )
200     {
201         return newBuilder( withDefaults ).build();
202     }
203 
204     /**
205      * Creates a new {@code CiManagement} builder instance.
206      * Equivalent to {@code newBuilder( true )}.
207      * @see #newBuilder(boolean)
208      *
209      * @return a new {@code Builder}
210      */
211     @Nonnull
212     public static Builder newBuilder()
213     {
214         return newBuilder( true );
215     }
216 
217     /**
218      * Creates a new {@code CiManagement} builder instance using default values or not.
219      *
220      * @param withDefaults the boolean indicating whether default values should be used
221      * @return a new {@code Builder}
222      */
223     @Nonnull
224     public static Builder newBuilder( boolean withDefaults )
225     {
226         return new Builder( withDefaults );
227     }
228 
229     /**
230      * Creates a new {@code CiManagement} builder instance using the specified object as a basis.
231      * Equivalent to {@code newBuilder( from, false )}.
232      *
233      * @param from the {@code CiManagement} instance to use as a basis
234      * @return a new {@code Builder}
235      */
236     @Nonnull
237     public static Builder newBuilder( CiManagement from )
238     {
239         return newBuilder( from, false );
240     }
241 
242     /**
243      * Creates a new {@code CiManagement} builder instance using the specified object as a basis.
244      *
245      * @param from the {@code CiManagement} instance to use as a basis
246      * @param forceCopy the boolean indicating if a copy should be forced
247      * @return a new {@code Builder}
248      */
249     @Nonnull
250     public static Builder newBuilder( CiManagement from, boolean forceCopy )
251     {
252         return new Builder( from, forceCopy );
253     }
254 
255     /**
256      * Builder class used to create CiManagement instances.
257      * @see #with()
258      * @see #newBuilder()
259      */
260     @NotThreadSafe
261     public static class Builder
262     {
263         CiManagement base;
264         String system;
265         String url;
266         Collection<Notifier> notifiers;
267         Map<Object, InputLocation> locations;
268 
269         Builder( boolean withDefaults )
270         {
271             if ( withDefaults )
272             {
273             }
274         }
275 
276         Builder( CiManagement base, boolean forceCopy )
277         {
278             if ( forceCopy )
279             {
280                 this.system = base.system;
281                 this.url = base.url;
282                 this.notifiers = base.notifiers;
283             }
284             else
285             {
286                 this.base = base;
287             }
288         }
289 
290         @Nonnull
291         public Builder system( String system )
292         {
293             this.system = system;
294             return this;
295         }
296 
297         @Nonnull
298         public Builder url( String url )
299         {
300             this.url = url;
301             return this;
302         }
303 
304         @Nonnull
305         public Builder notifiers( Collection<Notifier> notifiers )
306         {
307             this.notifiers = notifiers;
308             return this;
309         }
310 
311 
312         @Nonnull
313         public Builder location( Object key, InputLocation location )
314         {
315             if ( location != null )
316             {
317                 if ( this.locations == null )
318                 {
319                     this.locations = new HashMap<>();
320                 }
321                 this.locations.put( key, location );
322             }
323             return this;
324         }
325 
326         @Nonnull
327         public CiManagement build()
328         {
329             if ( base != null
330                     && ( system == null || system == base.system )
331                     && ( url == null || url == base.url )
332                     && ( notifiers == null || notifiers == base.notifiers )
333             )
334             {
335                 return base;
336             }
337             Map<Object, InputLocation> locations = null;
338             InputLocation location = null;
339             InputLocation systemLocation = null;
340             InputLocation urlLocation = null;
341             InputLocation notifiersLocation = null;
342             if ( this.locations != null )
343             {
344                 locations = this.locations;
345                 location = locations.remove( "" );
346                 systemLocation = locations.remove( "system" );
347                 urlLocation = locations.remove( "url" );
348                 notifiersLocation = locations.remove( "notifiers" );
349             }
350             return new CiManagement(
351                 system != null ? system : ( base != null ? base.system : null ),
352                 url != null ? url : ( base != null ? base.url : null ),
353                 notifiers != null ? notifiers : ( base != null ? base.notifiers : null ),
354                 locations != null ? locations : ( base != null ? base.locations : null ),
355                 location != null ? location : ( base != null ? base.location : null ),
356                 systemLocation != null ? systemLocation : ( base != null ? base.systemLocation : null ),
357                 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null ),
358                 notifiersLocation != null ? notifiersLocation : ( base != null ? base.notifiersLocation : null )
359             );
360         }
361     }
362 
363 }