001    /*
002     * #%L
003     * License Maven Plugin
004     *
005     * $Id: ProjectLicenseInfo.java 13877 2011-04-07 21:57:59Z pgier $
006     * $HeadURL: http://svn.codehaus.org/mojo/tags/license-maven-plugin-1.0/src/main/java/org/codehaus/mojo/license/model/ProjectLicenseInfo.java $
007     * %%
008     * Copyright (C) 2010 - 2011 Codehaus
009     * %%
010     * This program is free software: you can redistribute it and/or modify
011     * it under the terms of the GNU Lesser General Public License as 
012     * published by the Free Software Foundation, either version 3 of the 
013     * License, or (at your option) any later version.
014     * 
015     * This program is distributed in the hope that it will be useful,
016     * but WITHOUT ANY WARRANTY; without even the implied warranty of
017     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
018     * GNU General Lesser Public License for more details.
019     * 
020     * You should have received a copy of the GNU General Lesser Public 
021     * License along with this program.  If not, see
022     * <http://www.gnu.org/licenses/lgpl-3.0.html>.
023     * #L%
024     */
025    package org.codehaus.mojo.license.model;
026    
027    import org.apache.maven.artifact.Artifact;
028    import org.apache.maven.model.License;
029    
030    import java.util.ArrayList;
031    import java.util.List;
032    
033    /**
034     * Contains the license information for a single project/dependency
035     *
036     * @author pgier
037     * @since 1.0
038     */
039    public class ProjectLicenseInfo
040    {
041        private String groupId;
042    
043        private String artifactId;
044    
045        private String version;
046    
047        private List<License> licenses = new ArrayList<License>();
048    
049        private String licenseResolutionResult;
050    
051        public String getLicenseResolutionResult()
052        {
053            return licenseResolutionResult;
054        }
055    
056        public void setLicenseResolutionResult( String licenseResolutionResult )
057        {
058            this.licenseResolutionResult = licenseResolutionResult;
059        }
060    
061        /**
062         * Default constructor
063         */
064        public ProjectLicenseInfo()
065        {
066    
067        }
068    
069        public ProjectLicenseInfo( String groupId, String artifactId, String version )
070        {
071            this.groupId = groupId;
072            this.artifactId = artifactId;
073            this.version = version;
074        }
075    
076        public String getGroupId()
077        {
078            return groupId;
079        }
080    
081        public void setGroupId( String groupId )
082        {
083            this.groupId = groupId;
084        }
085    
086        public String getArtifactId()
087        {
088            return artifactId;
089        }
090    
091        public void setArtifactId( String artifactId )
092        {
093            this.artifactId = artifactId;
094        }
095    
096        public String getVersion()
097        {
098            return version;
099        }
100    
101        public void setVersion( String version )
102        {
103            this.version = version;
104        }
105    
106        public List<License> getLicenses()
107        {
108            return licenses;
109        }
110    
111        public void setLicenses( List<License> licenses )
112        {
113            this.licenses = licenses;
114        }
115    
116        public void addLicense( License license )
117        {
118            licenses.add( license );
119        }
120    
121        public String toString()
122        {
123            return getId();
124        }
125    
126        /**
127         * The unique ID for the project
128         *
129         * @return String containing "groupId:artifactId"
130         */
131        public String getId()
132        {
133            return groupId + ":" + artifactId;
134        }
135    
136        /**
137         * Compare this artifact to another ProjectLicenseInfo, or compare to an instance
138         * of org.apache.maven.artifact.Artifact
139         */
140        public boolean equals( Object compareTo )
141        {
142            if ( compareTo instanceof ProjectLicenseInfo )
143            {
144                ProjectLicenseInfo compare = (ProjectLicenseInfo) compareTo;
145                if ( groupId.equals( compare.getGroupId() ) && artifactId.equals( compare.getArtifactId() ) )
146                {
147                    return true;
148                }
149            }
150            if ( compareTo instanceof Artifact )
151            {
152                Artifact compare = (Artifact) compareTo;
153                if ( groupId.equals( compare.getGroupId() ) && artifactId.equals( compare.getArtifactId() ) )
154                {
155                    return true;
156                }
157            }
158            return false;
159        }
160    
161        public int hashCode()
162        {
163            return getId().hashCode();
164        }
165    
166    }