001package org.apache.maven.plugins.enforcer.utils;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.ArrayList;
023import java.util.List;
024
025import org.apache.maven.model.Plugin;
026import org.apache.maven.model.ReportPlugin;
027
028public class PluginWrapper
029{
030    private String groupId;
031
032    private String artifactId;
033
034    private String version;
035
036    private String source;
037
038    public static List<PluginWrapper> addAll( List<?> plugins, String source )
039    {
040        List<PluginWrapper> results = null;
041
042        if ( !plugins.isEmpty() )
043        {
044            results = new ArrayList<PluginWrapper>( plugins.size() );
045            for ( Object o : plugins )
046            {
047                if ( o instanceof Plugin )
048                {
049                    results.add( new PluginWrapper( (Plugin) o, source ) );
050                }
051                else
052                {
053                    if ( o instanceof ReportPlugin )
054                    {
055                        results.add( new PluginWrapper( (ReportPlugin) o, source ) );
056                    }
057                }
058
059            }
060        }
061        return results;
062    }
063
064    public PluginWrapper( Plugin plugin, String source )
065    {
066        setGroupId( plugin.getGroupId() );
067        setArtifactId( plugin.getArtifactId() );
068        setVersion( plugin.getVersion() );
069        setSource( source );
070    }
071
072    public PluginWrapper( ReportPlugin plugin, String source )
073    {
074        setGroupId( plugin.getGroupId() );
075        setArtifactId( plugin.getArtifactId() );
076        setVersion( plugin.getVersion() );
077        setSource( source );
078    }
079
080    public String getGroupId()
081    {
082        return groupId;
083    }
084
085    public void setGroupId( String groupId )
086    {
087        this.groupId = groupId;
088    }
089
090    public String getArtifactId()
091    {
092        return artifactId;
093    }
094
095    public void setArtifactId( String artifactId )
096    {
097        this.artifactId = artifactId;
098    }
099
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}