View Javadoc

1   /*
2    * #%L
3    * License Maven Plugin
4    *
5    * $Id: ProjectLicenseInfo.java 13877 2011-04-07 21:57:59Z pgier $
6    * $HeadURL: http://svn.codehaus.org/mojo/tags/license-maven-plugin-1.0/src/main/java/org/codehaus/mojo/license/model/ProjectLicenseInfo.java $
7    * %%
8    * Copyright (C) 2010 - 2011 Codehaus
9    * %%
10   * This program is free software: you can redistribute it and/or modify
11   * it under the terms of the GNU Lesser General Public License as 
12   * published by the Free Software Foundation, either version 3 of the 
13   * License, or (at your option) any later version.
14   * 
15   * This program is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU General Lesser Public License for more details.
19   * 
20   * You should have received a copy of the GNU General Lesser Public 
21   * License along with this program.  If not, see
22   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
23   * #L%
24   */
25  package org.codehaus.mojo.license.model;
26  
27  import org.apache.maven.artifact.Artifact;
28  import org.apache.maven.model.License;
29  
30  import java.util.ArrayList;
31  import java.util.List;
32  
33  /**
34   * Contains the license information for a single project/dependency
35   *
36   * @author pgier
37   * @since 1.0
38   */
39  public class ProjectLicenseInfo
40  {
41      private String groupId;
42  
43      private String artifactId;
44  
45      private String version;
46  
47      private List<License> licenses = new ArrayList<License>();
48  
49      private String licenseResolutionResult;
50  
51      public String getLicenseResolutionResult()
52      {
53          return licenseResolutionResult;
54      }
55  
56      public void setLicenseResolutionResult( String licenseResolutionResult )
57      {
58          this.licenseResolutionResult = licenseResolutionResult;
59      }
60  
61      /**
62       * Default constructor
63       */
64      public ProjectLicenseInfo()
65      {
66  
67      }
68  
69      public ProjectLicenseInfo( String groupId, String artifactId, String version )
70      {
71          this.groupId = groupId;
72          this.artifactId = artifactId;
73          this.version = version;
74      }
75  
76      public String getGroupId()
77      {
78          return groupId;
79      }
80  
81      public void setGroupId( String groupId )
82      {
83          this.groupId = groupId;
84      }
85  
86      public String getArtifactId()
87      {
88          return artifactId;
89      }
90  
91      public void setArtifactId( String artifactId )
92      {
93          this.artifactId = artifactId;
94      }
95  
96      public String getVersion()
97      {
98          return version;
99      }
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 }