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 ReportSet
33 extends ConfigurationContainer
34 implements Serializable, InputLocationTracker
35 {
36
37
38
39
40 final String id;
41
42
43
44 final List<String> reports;
45
46
47
48
49
50 protected ReportSet(Builder builder) {
51 super(builder);
52 this.id = builder.id != null ? builder.id : (builder.base != null ? builder.base.id : null);
53 this.reports = ImmutableCollections.copy(builder.reports != null ? builder.reports : (builder.base != null ? builder.base.reports : null));
54 }
55
56
57
58
59
60
61
62 public String getId() {
63 return this.id;
64 }
65
66
67
68
69
70
71 @Nonnull
72 public List<String> getReports() {
73 return this.reports;
74 }
75
76
77
78
79
80
81 @Nonnull
82 public Builder with() {
83 return newBuilder(this);
84 }
85
86
87
88
89
90
91 @Nonnull
92 public ReportSet withInherited(String inherited) {
93 return newBuilder(this, true).inherited(inherited).build();
94 }
95
96
97
98
99
100
101 @Nonnull
102 public ReportSet withConfiguration(XmlNode configuration) {
103 return newBuilder(this, true).configuration(configuration).build();
104 }
105
106
107
108
109
110
111 @Nonnull
112 public ReportSet withId(String id) {
113 return newBuilder(this, true).id(id).build();
114 }
115
116
117
118
119
120
121 @Nonnull
122 public ReportSet withReports(Collection<String> reports) {
123 return newBuilder(this, true).reports(reports).build();
124 }
125
126
127
128
129
130
131
132
133 @Nonnull
134 public static ReportSet newInstance() {
135 return newInstance(true);
136 }
137
138
139
140
141
142
143
144
145 @Nonnull
146 public static ReportSet newInstance(boolean withDefaults) {
147 return newBuilder(withDefaults).build();
148 }
149
150
151
152
153
154
155
156
157 @Nonnull
158 public static Builder newBuilder() {
159 return newBuilder(true);
160 }
161
162
163
164
165
166
167
168 @Nonnull
169 public static Builder newBuilder(boolean withDefaults) {
170 return new Builder(withDefaults);
171 }
172
173
174
175
176
177
178
179
180 @Nonnull
181 public static Builder newBuilder(ReportSet from) {
182 return newBuilder(from, false);
183 }
184
185
186
187
188
189
190
191
192 @Nonnull
193 public static Builder newBuilder(ReportSet from, boolean forceCopy) {
194 return new Builder(from, forceCopy);
195 }
196
197
198
199
200
201
202 @NotThreadSafe
203 public static class Builder
204 extends ConfigurationContainer.Builder
205 {
206 ReportSet base;
207 String id;
208 Collection<String> reports;
209
210 protected Builder(boolean withDefaults) {
211 super(withDefaults);
212 if (withDefaults) {
213 this.id = "default";
214 }
215 }
216
217 protected Builder(ReportSet base, boolean forceCopy) {
218 super(base, forceCopy);
219 if (forceCopy) {
220 this.id = base.id;
221 this.reports = base.reports;
222 this.locations = base.locations;
223 this.importedFrom = base.importedFrom;
224 } else {
225 this.base = base;
226 }
227 }
228
229 @Nonnull
230 public Builder inherited(String inherited) {
231 this.inherited = inherited;
232 return this;
233 }
234
235 @Nonnull
236 public Builder configuration(XmlNode configuration) {
237 this.configuration = configuration;
238 return this;
239 }
240
241 @Nonnull
242 public Builder id(String id) {
243 this.id = id;
244 return this;
245 }
246
247 @Nonnull
248 public Builder reports(Collection<String> reports) {
249 this.reports = reports;
250 return this;
251 }
252
253
254 @Nonnull
255 public Builder location(Object key, InputLocation location) {
256 if (location != null) {
257 if (!(this.locations instanceof HashMap)) {
258 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
259 }
260 this.locations.put(key, location);
261 }
262 return this;
263 }
264
265 @Nonnull
266 public Builder importedFrom(InputLocation importedFrom) {
267 this.importedFrom = importedFrom;
268 return this;
269 }
270
271 @Nonnull
272 public ReportSet build() {
273
274 if (base != null
275 && (inherited == null || inherited == base.inherited)
276 && (configuration == null || configuration == base.configuration)
277 && (id == null || id == base.id)
278 && (reports == null || reports == base.reports)
279 ) {
280 return base;
281 }
282 return new ReportSet(this);
283 }
284
285 }
286
287
288
289 @Override
290 public String toString() {
291 return getId();
292 }
293
294
295 }