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