View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model-v3.vm
3   //  template, any modifications will be overwritten.
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 (!Objects.equals(reportSets, getReportSets())) {
104             update(getDelegate().withReportSets(
105                    reportSets.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
106             reportSets.forEach(e -> e.childrenTracking = this::replace);
107         }
108     }
109 
110     public void addReportSet(ReportSet reportSet) {
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         update(getDelegate().withReportSets(
119                getDelegate().getReportSets().stream()
120                         .filter(e -> !Objects.equals(e, reportSet))
121                         .collect(Collectors.toList())));
122         reportSet.childrenTracking = null;
123     }
124 
125     public InputLocation getLocation(Object key) {
126         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
127         return loc != null ? new InputLocation(loc) : null;
128     }
129 
130     public void setLocation(Object key, InputLocation location) {
131         update(org.apache.maven.api.model.ReportPlugin.newBuilder(getDelegate(), true)
132                         .location(key, location.toApiLocation()).build());
133     }
134 
135     protected boolean replace(Object oldDelegate, Object newDelegate) {
136         if (super.replace(oldDelegate, newDelegate)) {
137             return true;
138         }
139         if (getDelegate().getReportSets().contains(oldDelegate)) {
140             List<org.apache.maven.api.model.ReportSet> list = new ArrayList<>(getDelegate().getReportSets());
141             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.ReportSet) newDelegate : d);
142             update(getDelegate().withReportSets(list));
143             return true;
144         }
145         return false;
146     }
147 
148     public static List<org.apache.maven.api.model.ReportPlugin> reportPluginToApiV4(List<ReportPlugin> list) {
149         return list != null ? new WrapperList<>(list, ReportPlugin::getDelegate, ReportPlugin::new) : null;
150     }
151 
152     public static List<ReportPlugin> reportPluginToApiV3(List<org.apache.maven.api.model.ReportPlugin> list) {
153         return list != null ? new WrapperList<>(list, ReportPlugin::new, ReportPlugin::getDelegate) : null;
154     }
155 
156 
157             
158     private java.util.Map<String, ReportSet> reportSetMap = null;
159 
160     /**
161      * Reset the {@code reportSetMap} field to {@code null}
162      */
163     public void flushReportSetMap()
164     {
165         this.reportSetMap = null;
166     }
167 
168     /**
169      * @return a Map of reportSets field with {@code ReportSet#getId()} as key
170      * @see ReportSet#getId()
171      */
172     public java.util.Map<String, ReportSet> getReportSetsAsMap()
173     {
174         if ( reportSetMap == null )
175         {
176             reportSetMap = new java.util.LinkedHashMap<String, ReportSet>();
177             if ( getReportSets() != null )
178             {
179                 for ( java.util.Iterator<ReportSet> i = getReportSets().iterator(); i.hasNext(); )
180                 {
181                     ReportSet reportSet = (ReportSet) i.next();
182                     reportSetMap.put( reportSet.getId(), reportSet );
183                 }
184             }
185         }
186 
187         return reportSetMap;
188     }
189 
190     /**
191      * @return the key of the report plugin, ie {@code groupId:artifactId}
192      */
193     public String getKey()
194     {
195         return constructKey( getGroupId(), getArtifactId() );
196     }
197 
198     /**
199      * @param groupId The group ID of the plugin in the repository
200      * @param artifactId The artifact ID of the reporting plugin in the repository
201      * @return the key of the report plugin, ie {@code groupId:artifactId}
202      */
203     public static String constructKey( String groupId, String artifactId )
204     {
205         return groupId + ":" + artifactId;
206     }
207             
208           
209 }