1
2
3
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 java.util.Objects;
15 import java.util.Optional;
16 import java.util.Set;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
19 import org.apache.maven.api.annotations.Experimental;
20 import org.apache.maven.api.annotations.Generated;
21 import org.apache.maven.api.annotations.Immutable;
22 import org.apache.maven.api.annotations.Nonnull;
23 import org.apache.maven.api.annotations.NotThreadSafe;
24 import org.apache.maven.api.annotations.ThreadSafe;
25 import org.apache.maven.api.xml.XmlNode;
26
27
28
29
30 @Experimental
31 @Generated @ThreadSafe @Immutable
32 public class ReportPlugin
33 extends ConfigurationContainer
34 implements Serializable, InputLocationTracker
35 {
36
37
38
39 final String groupId;
40
41
42
43 final String artifactId;
44
45
46
47
48 final String version;
49
50
51
52
53 final List<ReportSet> reportSets;
54
55
56
57
58
59 protected ReportPlugin(Builder builder) {
60 super(builder);
61 this.groupId = builder.groupId != null ? builder.groupId : (builder.base != null ? builder.base.groupId : null);
62 this.artifactId = builder.artifactId != null ? builder.artifactId : (builder.base != null ? builder.base.artifactId : null);
63 this.version = builder.version != null ? builder.version : (builder.base != null ? builder.base.version : null);
64 this.reportSets = ImmutableCollections.copy(builder.reportSets != null ? builder.reportSets : (builder.base != null ? builder.base.reportSets : null));
65 }
66
67
68
69
70
71
72 public String getGroupId() {
73 return this.groupId;
74 }
75
76
77
78
79
80
81 public String getArtifactId() {
82 return this.artifactId;
83 }
84
85
86
87
88
89
90
91 public String getVersion() {
92 return this.version;
93 }
94
95
96
97
98
99
100
101 @Nonnull
102 public List<ReportSet> getReportSets() {
103 return this.reportSets;
104 }
105
106
107
108
109
110
111 @Nonnull
112 public Builder with() {
113 return newBuilder(this);
114 }
115
116
117
118
119
120
121 @Nonnull
122 public ReportPlugin withInherited(String inherited) {
123 return newBuilder(this, true).inherited(inherited).build();
124 }
125
126
127
128
129
130
131 @Nonnull
132 public ReportPlugin withConfiguration(XmlNode configuration) {
133 return newBuilder(this, true).configuration(configuration).build();
134 }
135
136
137
138
139
140
141 @Nonnull
142 public ReportPlugin withGroupId(String groupId) {
143 return newBuilder(this, true).groupId(groupId).build();
144 }
145
146
147
148
149
150
151 @Nonnull
152 public ReportPlugin withArtifactId(String artifactId) {
153 return newBuilder(this, true).artifactId(artifactId).build();
154 }
155
156
157
158
159
160
161 @Nonnull
162 public ReportPlugin withVersion(String version) {
163 return newBuilder(this, true).version(version).build();
164 }
165
166
167
168
169
170
171 @Nonnull
172 public ReportPlugin withReportSets(Collection<ReportSet> reportSets) {
173 return newBuilder(this, true).reportSets(reportSets).build();
174 }
175
176
177
178
179
180
181
182
183 @Nonnull
184 public static ReportPlugin newInstance() {
185 return newInstance(true);
186 }
187
188
189
190
191
192
193
194
195 @Nonnull
196 public static ReportPlugin newInstance(boolean withDefaults) {
197 return newBuilder(withDefaults).build();
198 }
199
200
201
202
203
204
205
206
207 @Nonnull
208 public static Builder newBuilder() {
209 return newBuilder(true);
210 }
211
212
213
214
215
216
217
218 @Nonnull
219 public static Builder newBuilder(boolean withDefaults) {
220 return new Builder(withDefaults);
221 }
222
223
224
225
226
227
228
229
230 @Nonnull
231 public static Builder newBuilder(ReportPlugin from) {
232 return newBuilder(from, false);
233 }
234
235
236
237
238
239
240
241
242 @Nonnull
243 public static Builder newBuilder(ReportPlugin from, boolean forceCopy) {
244 return new Builder(from, forceCopy);
245 }
246
247
248
249
250
251
252 @NotThreadSafe
253 public static class Builder
254 extends ConfigurationContainer.Builder
255 {
256 ReportPlugin base;
257 String groupId;
258 String artifactId;
259 String version;
260 Collection<ReportSet> reportSets;
261
262 protected Builder(boolean withDefaults) {
263 super(withDefaults);
264 if (withDefaults) {
265 this.groupId = "org.apache.maven.plugins";
266 }
267 }
268
269 protected Builder(ReportPlugin base, boolean forceCopy) {
270 super(base, forceCopy);
271 if (forceCopy) {
272 this.groupId = base.groupId;
273 this.artifactId = base.artifactId;
274 this.version = base.version;
275 this.reportSets = base.reportSets;
276 this.locations = base.locations;
277 this.importedFrom = base.importedFrom;
278 } else {
279 this.base = base;
280 }
281 }
282
283 @Nonnull
284 public Builder inherited(String inherited) {
285 this.inherited = inherited;
286 return this;
287 }
288
289 @Nonnull
290 public Builder configuration(XmlNode configuration) {
291 this.configuration = configuration;
292 return this;
293 }
294
295 @Nonnull
296 public Builder groupId(String groupId) {
297 this.groupId = groupId;
298 return this;
299 }
300
301 @Nonnull
302 public Builder artifactId(String artifactId) {
303 this.artifactId = artifactId;
304 return this;
305 }
306
307 @Nonnull
308 public Builder version(String version) {
309 this.version = version;
310 return this;
311 }
312
313 @Nonnull
314 public Builder reportSets(Collection<ReportSet> reportSets) {
315 this.reportSets = reportSets;
316 return this;
317 }
318
319
320 @Nonnull
321 public Builder location(Object key, InputLocation location) {
322 if (location != null) {
323 if (!(this.locations instanceof HashMap)) {
324 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
325 }
326 this.locations.put(key, location);
327 }
328 return this;
329 }
330
331 @Nonnull
332 public Builder importedFrom(InputLocation importedFrom) {
333 this.importedFrom = importedFrom;
334 return this;
335 }
336
337 @Nonnull
338 public ReportPlugin build() {
339
340 if (base != null
341 && (inherited == null || inherited == base.inherited)
342 && (configuration == null || configuration == base.configuration)
343 && (groupId == null || groupId == base.groupId)
344 && (artifactId == null || artifactId == base.artifactId)
345 && (version == null || version == base.version)
346 && (reportSets == null || reportSets == base.reportSets)
347 ) {
348 return base;
349 }
350 return new ReportPlugin(this);
351 }
352
353 }
354
355
356
357 private java.util.Map<String, ReportSet> reportSetMap = null;
358
359
360
361
362 public void flushReportSetMap() {
363 this.reportSetMap = null;
364 }
365
366
367
368
369
370 public java.util.Map<String, ReportSet> getReportSetsAsMap() {
371 if (reportSetMap == null) {
372 reportSetMap = new java.util.LinkedHashMap<String, ReportSet>();
373 if (getReportSets() != null) {
374 for (java.util.Iterator<ReportSet> i = getReportSets().iterator(); i.hasNext(); ) {
375 ReportSet reportSet = (ReportSet) i.next();
376 reportSetMap.put(reportSet.getId(), reportSet);
377 }
378 }
379 }
380
381 return reportSetMap;
382 }
383
384
385
386
387 public String getKey() {
388 return constructKey(getGroupId(), getArtifactId());
389 }
390
391
392
393
394
395
396 public static String constructKey(String groupId, String artifactId) {
397 return groupId + ":" + artifactId;
398 }
399
400
401 }