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