View Javadoc
1   package org.apache.maven.plugins.enforcer.utils;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.apache.maven.model.Plugin;
26  import org.apache.maven.model.ReportPlugin;
27  
28  /**
29   * @author Brian Fox
30   *
31   */
32  public class PluginWrapper
33  {
34      private String groupId;
35  
36      private String artifactId;
37  
38      private String version;
39  
40      private String source;
41  
42      public static List<PluginWrapper> addAll( List<?> plugins, String source )
43      {
44          List<PluginWrapper> results = null;
45  
46          if ( !plugins.isEmpty() )
47          {
48              results = new ArrayList<PluginWrapper>( plugins.size() );
49              for ( Object o : plugins )
50              {
51                  if ( o instanceof Plugin )
52                  {
53                      results.add( new PluginWrapper( (Plugin) o, source ) );
54                  }
55                  else
56                  {
57                      if ( o instanceof ReportPlugin )
58                      {
59                          results.add( new PluginWrapper( (ReportPlugin) o, source ) );
60                      }
61                  }
62  
63              }
64          }
65          return results;
66      }
67  
68      public PluginWrapper( Plugin plugin, String source )
69      {
70          setGroupId( plugin.getGroupId() );
71          setArtifactId( plugin.getArtifactId() );
72          setVersion( plugin.getVersion() );
73          setSource( source );
74      }
75  
76      public PluginWrapper( ReportPlugin plugin, String source )
77      {
78          setGroupId( plugin.getGroupId() );
79          setArtifactId( plugin.getArtifactId() );
80          setVersion( plugin.getVersion() );
81          setSource( source );
82      }
83  
84      public String getGroupId()
85      {
86          return groupId;
87      }
88  
89      public void setGroupId( String groupId )
90      {
91          this.groupId = groupId;
92      }
93  
94      public String getArtifactId()
95      {
96          return artifactId;
97      }
98  
99      public void setArtifactId( String artifactId )
100     {
101         this.artifactId = artifactId;
102     }
103 
104     public String getVersion()
105     {
106         return version;
107     }
108 
109     public void setVersion( String version )
110     {
111         this.version = version;
112     }
113 
114     public String getSource()
115     {
116         return source;
117     }
118 
119     public void setSource( String source )
120     {
121         this.source = source;
122     }
123 }