1
2
3
4
5 package org.apache.maven.model;
6
7 import java.io.Serializable;
8 import java.util.AbstractList;
9 import java.util.ArrayList;
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.stream.Collectors;
16 import java.util.stream.Stream;
17 import org.apache.maven.api.annotations.Generated;
18 import org.apache.maven.api.annotations.Nonnull;
19 import org.codehaus.plexus.util.xml.Xpp3Dom;
20
21 @Generated
22 public class ReportPlugin
23 extends ConfigurationContainer
24 implements Serializable, Cloneable
25 {
26
27 public ReportPlugin() {
28 this(org.apache.maven.api.model.ReportPlugin.newInstance());
29 }
30
31 public ReportPlugin(org.apache.maven.api.model.ReportPlugin delegate) {
32 this(delegate, null);
33 }
34
35 public ReportPlugin(org.apache.maven.api.model.ReportPlugin delegate, BaseObject parent) {
36 super(delegate, parent);
37 }
38
39 public ReportPlugin clone(){
40 return new ReportPlugin(getDelegate());
41 }
42
43 @Override
44 public org.apache.maven.api.model.ReportPlugin getDelegate() {
45 return (org.apache.maven.api.model.ReportPlugin) super.getDelegate();
46 }
47
48 @Override
49 public boolean equals(Object o) {
50 if (this == o) {
51 return true;
52 }
53 if (o == null || !(o instanceof ReportPlugin)) {
54 return false;
55 }
56 ReportPlugin that = (ReportPlugin) o;
57 return Objects.equals(this.delegate, that.delegate);
58 }
59
60 @Override
61 public int hashCode() {
62 return getDelegate().hashCode();
63 }
64
65 public String getGroupId() {
66 return getDelegate().getGroupId();
67 }
68
69 public void setGroupId(String groupId) {
70 if (!Objects.equals(groupId, getGroupId())) {
71 update(getDelegate().withGroupId(groupId));
72 }
73 }
74
75 public String getArtifactId() {
76 return getDelegate().getArtifactId();
77 }
78
79 public void setArtifactId(String artifactId) {
80 if (!Objects.equals(artifactId, getArtifactId())) {
81 update(getDelegate().withArtifactId(artifactId));
82 }
83 }
84
85 public String getVersion() {
86 return getDelegate().getVersion();
87 }
88
89 public void setVersion(String version) {
90 if (!Objects.equals(version, getVersion())) {
91 update(getDelegate().withVersion(version));
92 }
93 }
94
95 @Nonnull
96 public List<ReportSet> getReportSets() {
97 return new WrapperList<ReportSet, org.apache.maven.api.model.ReportSet>(
98 () -> getDelegate().getReportSets(), l -> update(getDelegate().withReportSets(l)),
99 d -> new ReportSet(d, this), ReportSet::getDelegate);
100 }
101
102 public void setReportSets(List<ReportSet> reportSets) {
103 if (reportSets == null) {
104 reportSets = Collections.emptyList();
105 }
106 if (!Objects.equals(reportSets, getReportSets())) {
107 update(getDelegate().withReportSets(
108 reportSets.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
109 reportSets.forEach(e -> e.childrenTracking = this::replace);
110 }
111 }
112
113 public void addReportSet(ReportSet reportSet) {
114 update(getDelegate().withReportSets(
115 Stream.concat(getDelegate().getReportSets().stream(), Stream.of(reportSet.getDelegate()))
116 .collect(Collectors.toList())));
117 reportSet.childrenTracking = this::replace;
118 }
119
120 public void removeReportSet(ReportSet reportSet) {
121 update(getDelegate().withReportSets(
122 getDelegate().getReportSets().stream()
123 .filter(e -> !Objects.equals(e, reportSet))
124 .collect(Collectors.toList())));
125 reportSet.childrenTracking = null;
126 }
127
128 public InputLocation getLocation(Object key) {
129 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
130 return loc != null ? new InputLocation(loc) : null;
131 }
132
133 public void setLocation(Object key, InputLocation location) {
134 update(org.apache.maven.api.model.ReportPlugin.newBuilder(getDelegate(), true)
135 .location(key, location.toApiLocation()).build());
136 }
137
138 protected boolean replace(Object oldDelegate, Object newDelegate) {
139 if (super.replace(oldDelegate, newDelegate)) {
140 return true;
141 }
142 if (getDelegate().getReportSets().contains(oldDelegate)) {
143 List<org.apache.maven.api.model.ReportSet> list = new ArrayList<>(getDelegate().getReportSets());
144 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.ReportSet) newDelegate : d);
145 update(getDelegate().withReportSets(list));
146 return true;
147 }
148 return false;
149 }
150
151 public static List<org.apache.maven.api.model.ReportPlugin> reportPluginToApiV4(List<ReportPlugin> list) {
152 return list != null ? new WrapperList<>(list, ReportPlugin::getDelegate, ReportPlugin::new) : null;
153 }
154
155 public static List<ReportPlugin> reportPluginToApiV3(List<org.apache.maven.api.model.ReportPlugin> list) {
156 return list != null ? new WrapperList<>(list, ReportPlugin::new, ReportPlugin::getDelegate) : null;
157 }
158
159
160
161 private java.util.Map<String, ReportSet> reportSetMap = null;
162
163
164
165
166 public void flushReportSetMap()
167 {
168 this.reportSetMap = null;
169 }
170
171
172
173
174
175 public java.util.Map<String, ReportSet> getReportSetsAsMap()
176 {
177 if ( reportSetMap == null )
178 {
179 reportSetMap = new java.util.LinkedHashMap<String, ReportSet>();
180 if ( getReportSets() != null )
181 {
182 for ( java.util.Iterator<ReportSet> i = getReportSets().iterator(); i.hasNext(); )
183 {
184 ReportSet reportSet = (ReportSet) i.next();
185 reportSetMap.put( reportSet.getId(), reportSet );
186 }
187 }
188 }
189
190 return reportSetMap;
191 }
192
193
194
195
196 public String getKey()
197 {
198 return constructKey( getGroupId(), getArtifactId() );
199 }
200
201
202
203
204
205
206 public static String constructKey( String groupId, String artifactId )
207 {
208 return groupId + ":" + artifactId;
209 }
210
211
212 }