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