View Javadoc
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.model;
6   
7   import java.io.Serializable;
8   import java.util.ArrayList;
9   import java.util.Collection;
10  import java.util.Collections;
11  import java.util.HashMap;
12  import java.util.List;
13  import java.util.Map;
14  import org.apache.maven.api.annotations.Experimental;
15  import org.apache.maven.api.annotations.Generated;
16  import org.apache.maven.api.annotations.Immutable;
17  import org.apache.maven.api.annotations.Nonnull;
18  import org.apache.maven.api.annotations.NotThreadSafe;
19  import org.apache.maven.api.annotations.ThreadSafe;
20  
21  /**
22   * The {@code <ciManagement>} element contains information required to the
23   * continuous integration system of the project.
24   */
25  @Experimental
26  @Generated @ThreadSafe @Immutable
27  public class CiManagement
28      implements Serializable, InputLocationTracker
29  {
30      /**
31       * The name of the continuous integration system, e.g. {@code continuum}.
32       */
33      final String system;
34      /**
35       * URL for the continuous integration system used by the project if it has a web 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      /** Locations */
44      final Map<Object, InputLocation> locations;
45  
46      /**
47        * Constructor for this class, package protected.
48        * @see Builder#build()
49        */
50      CiManagement(
51          String system,
52          String url,
53          Collection<Notifier> notifiers,
54          Map<Object, InputLocation> locations
55      ) {
56          this.system = system;
57          this.url = url;
58          this.notifiers = ImmutableCollections.copy(notifiers);
59          this.locations = ImmutableCollections.copy(locations);
60      }
61  
62      /**
63       * The name of the continuous integration system, e.g. {@code continuum}.
64       *
65       * @return a {@code String}
66       */
67      public String getSystem() {
68          return this.system;
69      }
70  
71      /**
72       * URL for the continuous integration system used by the project if it has a web interface.
73       *
74       * @return a {@code String}
75       */
76      public String getUrl() {
77          return this.url;
78      }
79  
80      /**
81       * Configuration for notifying developers/users when a build is unsuccessful,
82       * including user information and notification mode.
83       *
84       * @return a {@code List<Notifier>}
85       */
86      @Nonnull
87      public List<Notifier> getNotifiers() {
88          return this.notifiers;
89      }
90  
91      /**
92       * Gets the location of the specified field in the input source.
93       */
94      public InputLocation getLocation(Object key) {
95          return locations != null ? locations.get(key) : null;
96      }
97  
98      /**
99       * Creates a new builder with this object as the basis.
100      *
101      * @return a {@code Builder}
102      */
103     @Nonnull
104     public Builder with() {
105         return newBuilder(this);
106     }
107     /**
108      * Creates a new {@code CiManagement} instance using the specified system.
109      *
110      * @param system the new {@code String} to use
111      * @return a {@code CiManagement} with the specified system
112      */
113     @Nonnull
114     public CiManagement withSystem(String system) {
115         return newBuilder(this, true).system(system).build();
116     }
117     /**
118      * Creates a new {@code CiManagement} instance using the specified url.
119      *
120      * @param url the new {@code String} to use
121      * @return a {@code CiManagement} with the specified url
122      */
123     @Nonnull
124     public CiManagement withUrl(String url) {
125         return newBuilder(this, true).url(url).build();
126     }
127     /**
128      * Creates a new {@code CiManagement} instance using the specified notifiers.
129      *
130      * @param notifiers the new {@code Collection<Notifier>} to use
131      * @return a {@code CiManagement} with the specified notifiers
132      */
133     @Nonnull
134     public CiManagement withNotifiers(Collection<Notifier> notifiers) {
135         return newBuilder(this, true).notifiers(notifiers).build();
136     }
137 
138     /**
139      * Creates a new {@code CiManagement} instance.
140      * Equivalent to {@code newInstance(true)}.
141      * @see #newInstance(boolean)
142      *
143      * @return a new {@code CiManagement}
144      */
145     @Nonnull
146     public static CiManagement newInstance() {
147         return newInstance(true);
148     }
149 
150     /**
151      * Creates a new {@code CiManagement} instance using default values or not.
152      * Equivalent to {@code newBuilder(withDefaults).build()}.
153      *
154      * @param withDefaults the boolean indicating whether default values should be used
155      * @return a new {@code CiManagement}
156      */
157     @Nonnull
158     public static CiManagement newInstance(boolean withDefaults) {
159         return newBuilder(withDefaults).build();
160     }
161 
162     /**
163      * Creates a new {@code CiManagement} builder instance.
164      * Equivalent to {@code newBuilder(true)}.
165      * @see #newBuilder(boolean)
166      *
167      * @return a new {@code Builder}
168      */
169     @Nonnull
170     public static Builder newBuilder() {
171         return newBuilder(true);
172     }
173 
174     /**
175      * Creates a new {@code CiManagement} builder instance using default values or not.
176      *
177      * @param withDefaults the boolean indicating whether default values should be used
178      * @return a new {@code Builder}
179      */
180     @Nonnull
181     public static Builder newBuilder(boolean withDefaults) {
182         return new Builder(withDefaults);
183     }
184 
185     /**
186      * Creates a new {@code CiManagement} builder instance using the specified object as a basis.
187      * Equivalent to {@code newBuilder(from, false)}.
188      *
189      * @param from the {@code CiManagement} instance to use as a basis
190      * @return a new {@code Builder}
191      */
192     @Nonnull
193     public static Builder newBuilder(CiManagement from) {
194         return newBuilder(from, false);
195     }
196 
197     /**
198      * Creates a new {@code CiManagement} builder instance using the specified object as a basis.
199      *
200      * @param from the {@code CiManagement} instance to use as a basis
201      * @param forceCopy the boolean indicating if a copy should be forced
202      * @return a new {@code Builder}
203      */
204     @Nonnull
205     public static Builder newBuilder(CiManagement from, boolean forceCopy) {
206         return new Builder(from, forceCopy);
207     }
208 
209     /**
210      * Builder class used to create CiManagement instances.
211      * @see #with()
212      * @see #newBuilder()
213      */
214     @NotThreadSafe
215     public static class Builder
216     {
217         CiManagement base;
218         String system;
219         String url;
220         Collection<Notifier> notifiers;
221         Map<Object, InputLocation> locations;
222 
223         Builder(boolean withDefaults) {
224             if (withDefaults) {
225             }
226         }
227 
228         Builder(CiManagement base, boolean forceCopy) {
229             if (forceCopy) {
230                 this.system = base.system;
231                 this.url = base.url;
232                 this.notifiers = base.notifiers;
233                 this.locations = base.locations;
234             } else {
235                 this.base = base;
236             }
237         }
238 
239         @Nonnull
240         public Builder system(String system) {
241             this.system = system;
242             return this;
243         }
244 
245         @Nonnull
246         public Builder url(String url) {
247             this.url = url;
248             return this;
249         }
250 
251         @Nonnull
252         public Builder notifiers(Collection<Notifier> notifiers) {
253             this.notifiers = notifiers;
254             return this;
255         }
256 
257 
258         @Nonnull
259         public Builder location(Object key, InputLocation location) {
260             if (location != null) {
261                 if (!(this.locations instanceof HashMap)) {
262                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
263                 }
264                 this.locations.put(key, location);
265             }
266             return this;
267         }
268 
269         @Nonnull
270         public CiManagement build() {
271             if (base != null
272                     && (system == null || system == base.system)
273                     && (url == null || url == base.url)
274                     && (notifiers == null || notifiers == base.notifiers)
275             ) {
276                 return base;
277             }
278             Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
279             Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
280             Map<Object, InputLocation> locations = new HashMap<>();
281             locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
282             locations.put("system", newlocs.containsKey("system") ? newlocs.get("system") : oldlocs.get("system"));
283             locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
284             locations.put("notifiers", newlocs.containsKey("notifiers") ? newlocs.get("notifiers") : oldlocs.get("notifiers"));
285             return new CiManagement(
286                 system != null ? system : (base != null ? base.system : null),
287                 url != null ? url : (base != null ? base.url : null),
288                 notifiers != null ? notifiers : (base != null ? base.notifiers : null),
289                 locations
290             );
291         }
292     }
293 
294 }