1
2
3
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
20
21
22 @Experimental
23 @Generated @ThreadSafe @Immutable
24 public class IssueManagement
25 implements Serializable, InputLocationTracker
26 {
27
28
29
30 final String system;
31
32
33
34 final String url;
35
36 final Map<Object, InputLocation> locations;
37
38
39
40
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
54
55
56
57 public String getSystem() {
58 return this.system;
59 }
60
61
62
63
64
65
66 public String getUrl() {
67 return this.url;
68 }
69
70
71
72
73 public InputLocation getLocation(Object key) {
74 return locations != null ? locations.get(key) : null;
75 }
76
77
78
79
80
81
82 @Nonnull
83 public Builder with() {
84 return newBuilder(this);
85 }
86
87
88
89
90
91
92 @Nonnull
93 public IssueManagement withSystem(String system) {
94 return newBuilder(this, true).system(system).build();
95 }
96
97
98
99
100
101
102 @Nonnull
103 public IssueManagement withUrl(String url) {
104 return newBuilder(this, true).url(url).build();
105 }
106
107
108
109
110
111
112
113
114 @Nonnull
115 public static IssueManagement newInstance() {
116 return newInstance(true);
117 }
118
119
120
121
122
123
124
125
126 @Nonnull
127 public static IssueManagement newInstance(boolean withDefaults) {
128 return newBuilder(withDefaults).build();
129 }
130
131
132
133
134
135
136
137
138 @Nonnull
139 public static Builder newBuilder() {
140 return newBuilder(true);
141 }
142
143
144
145
146
147
148
149 @Nonnull
150 public static Builder newBuilder(boolean withDefaults) {
151 return new Builder(withDefaults);
152 }
153
154
155
156
157
158
159
160
161 @Nonnull
162 public static Builder newBuilder(IssueManagement from) {
163 return newBuilder(from, false);
164 }
165
166
167
168
169
170
171
172
173 @Nonnull
174 public static Builder newBuilder(IssueManagement from, boolean forceCopy) {
175 return new Builder(from, forceCopy);
176 }
177
178
179
180
181
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> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
239 Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
240 Map<Object, InputLocation> locations = new HashMap<>();
241 locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
242 locations.put("system", newlocs.containsKey("system") ? newlocs.get("system") : oldlocs.get("system"));
243 locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
244 return new IssueManagement(
245 system != null ? system : (base != null ? base.system : null),
246 url != null ? url : (base != null ? base.url : null),
247 locations
248 );
249 }
250 }
251
252
253
254
255
256
257 public String toString()
258 {
259 return "IssueManagement {system=" + getSystem() + ", url=" + getUrl() + "}";
260 }
261
262
263 }