View Javadoc

1   /**
2    * Copyright 2010-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.codehaus.mojo.license.model;
17  
18  import org.apache.maven.artifact.Artifact;
19  import org.apache.maven.model.License;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  /**
25   * Contains the license information for a single project/dependency
26   *
27   * @author pgier
28   * @since 1.0
29   */
30  public class ProjectLicenseInfo
31  {
32      private String groupId;
33  
34      private String artifactId;
35  
36      private String version;
37  
38      private List<License> licenses = new ArrayList<License>();
39  
40      private String licenseResolutionResult;
41  
42      public String getLicenseResolutionResult()
43      {
44          return licenseResolutionResult;
45      }
46  
47      public void setLicenseResolutionResult( String licenseResolutionResult )
48      {
49          this.licenseResolutionResult = licenseResolutionResult;
50      }
51  
52      /**
53       * Default constructor
54       */
55      public ProjectLicenseInfo()
56      {
57  
58      }
59  
60      public ProjectLicenseInfo( String groupId, String artifactId, String version )
61      {
62          this.groupId = groupId;
63          this.artifactId = artifactId;
64          this.version = version;
65      }
66  
67      public String getGroupId()
68      {
69          return groupId;
70      }
71  
72      public void setGroupId( String groupId )
73      {
74          this.groupId = groupId;
75      }
76  
77      public String getArtifactId()
78      {
79          return artifactId;
80      }
81  
82      public void setArtifactId( String artifactId )
83      {
84          this.artifactId = artifactId;
85      }
86  
87      public String getVersion()
88      {
89          return version;
90      }
91  
92      public void setVersion( String version )
93      {
94          this.version = version;
95      }
96  
97      public List<License> getLicenses()
98      {
99          return licenses;
100     }
101 
102     public void setLicenses( List<License> licenses )
103     {
104         this.licenses = licenses;
105     }
106 
107     public void addLicense( License license )
108     {
109         licenses.add( license );
110     }
111 
112     public String toString()
113     {
114         return getId();
115     }
116 
117     /**
118      * The unique ID for the project
119      *
120      * @return String containing "groupId:artifactId"
121      */
122     public String getId()
123     {
124         return groupId + ":" + artifactId;
125     }
126 
127     /**
128      * Compare this artifact to another ProjectLicenseInfo, or compare to an instance
129      * of org.apache.maven.artifact.Artifact
130      */
131     public boolean equals( Object compareTo )
132     {
133         if ( compareTo instanceof ProjectLicenseInfo )
134         {
135             ProjectLicenseInfo compare = (ProjectLicenseInfo) compareTo;
136             if ( groupId.equals( compare.getGroupId() ) && artifactId.equals( compare.getArtifactId() ) )
137             {
138                 return true;
139             }
140         }
141         if ( compareTo instanceof Artifact )
142         {
143             Artifact compare = (Artifact) compareTo;
144             if ( groupId.equals( compare.getGroupId() ) && artifactId.equals( compare.getArtifactId() ) )
145             {
146                 return true;
147             }
148         }
149         return false;
150     }
151 
152     public int hashCode()
153     {
154         return getId().hashCode();
155     }
156 
157 }