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