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  public class PluginWrapper
29  {
30      private String groupId;
31  
32      private String artifactId;
33  
34      private String version;
35  
36      private String source;
37  
38      public static List<PluginWrapper> addAll( List<?> plugins, String source )
39      {
40          List<PluginWrapper> results = null;
41  
42          if ( !plugins.isEmpty() )
43          {
44              results = new ArrayList<PluginWrapper>( plugins.size() );
45              for ( Object o : plugins )
46              {
47                  if ( o instanceof Plugin )
48                  {
49                      results.add( new PluginWrapper( (Plugin) o, source ) );
50                  }
51                  else
52                  {
53                      if ( o instanceof ReportPlugin )
54                      {
55                          results.add( new PluginWrapper( (ReportPlugin) o, source ) );
56                      }
57                  }
58  
59              }
60          }
61          return results;
62      }
63  
64      public PluginWrapper( Plugin plugin, String source )
65      {
66          setGroupId( plugin.getGroupId() );
67          setArtifactId( plugin.getArtifactId() );
68          setVersion( plugin.getVersion() );
69          setSource( source );
70      }
71  
72      public PluginWrapper( ReportPlugin plugin, String source )
73      {
74          setGroupId( plugin.getGroupId() );
75          setArtifactId( plugin.getArtifactId() );
76          setVersion( plugin.getVersion() );
77          setSource( source );
78      }
79  
80      public String getGroupId()
81      {
82          return groupId;
83      }
84  
85      public void setGroupId( String groupId )
86      {
87          this.groupId = groupId;
88      }
89  
90      public String getArtifactId()
91      {
92          return artifactId;
93      }
94  
95      public void setArtifactId( String artifactId )
96      {
97          this.artifactId = artifactId;
98      }
99  
100     public String getVersion()
101     {
102         return version;
103     }
104 
105     public void setVersion( String version )
106     {
107         this.version = version;
108     }
109 
110     public String getSource()
111     {
112         return source;
113     }
114 
115     public void setSource( String source )
116     {
117         this.source = source;
118     }
119 }