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