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
028/**
029 * @author Brian Fox
030 *
031 */
032public class PluginWrapper
033{
034    private String groupId;
035
036    private String artifactId;
037
038    private String version;
039
040    private String source;
041
042    public static List<PluginWrapper> addAll( List<?> plugins, String source )
043    {
044        List<PluginWrapper> results = null;
045
046        if ( !plugins.isEmpty() )
047        {
048            results = new ArrayList<PluginWrapper>( plugins.size() );
049            for ( Object o : plugins )
050            {
051                if ( o instanceof Plugin )
052                {
053                    results.add( new PluginWrapper( (Plugin) o, source ) );
054                }
055                else
056                {
057                    if ( o instanceof ReportPlugin )
058                    {
059                        results.add( new PluginWrapper( (ReportPlugin) o, source ) );
060                    }
061                }
062
063            }
064        }
065        return results;
066    }
067
068    public PluginWrapper( Plugin plugin, String source )
069    {
070        setGroupId( plugin.getGroupId() );
071        setArtifactId( plugin.getArtifactId() );
072        setVersion( plugin.getVersion() );
073        setSource( source );
074    }
075
076    public PluginWrapper( ReportPlugin plugin, String source )
077    {
078        setGroupId( plugin.getGroupId() );
079        setArtifactId( plugin.getArtifactId() );
080        setVersion( plugin.getVersion() );
081        setSource( source );
082    }
083
084    public String getGroupId()
085    {
086        return groupId;
087    }
088
089    public void setGroupId( String groupId )
090    {
091        this.groupId = groupId;
092    }
093
094    public String getArtifactId()
095    {
096        return artifactId;
097    }
098
099    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}