View Javadoc
1   package org.apache.maven.plugin.compiler;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * Simple representation of Maven-coordinates of a dependency.
24   *
25   * @author Andreas Gudian
26   * @since 3.4
27   */
28  public class DependencyCoordinate
29  {
30      private String groupId;
31  
32      private String artifactId;
33  
34      private String version;
35  
36      private String classifier;
37  
38      private String type = "jar";
39  
40      public String getGroupId()
41      {
42          return groupId;
43      }
44  
45      public void setGroupId( String groupId )
46      {
47          this.groupId = groupId;
48      }
49  
50      public String getArtifactId()
51      {
52          return artifactId;
53      }
54  
55      public void setArtifactId( String artifactId )
56      {
57          this.artifactId = artifactId;
58      }
59  
60      public String getVersion()
61      {
62          return version;
63      }
64  
65      public void setVersion( String version )
66      {
67          this.version = version;
68      }
69  
70      public String getClassifier()
71      {
72          return classifier;
73      }
74  
75      public void setClassifier( String classifier )
76      {
77          this.classifier = classifier;
78      }
79  
80      public String getType()
81      {
82          return type;
83      }
84  
85      public void setType( String type )
86      {
87          this.type = type;
88      }
89  
90      @Override
91      public int hashCode()
92      {
93          final int prime = 31;
94          int result = 1;
95          result = prime * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() );
96          result = prime * result + ( ( classifier == null ) ? 0 : classifier.hashCode() );
97          result = prime * result + ( ( groupId == null ) ? 0 : groupId.hashCode() );
98          result = prime * result + ( ( type == null ) ? 0 : type.hashCode() );
99          result = prime * result + ( ( version == null ) ? 0 : version.hashCode() );
100         return result;
101     }
102 
103     @Override
104     public boolean equals( Object obj )
105     {
106         if ( this == obj )
107         {
108             return true;
109         }
110         if ( obj == null )
111         {
112             return false;
113         }
114         if ( getClass() != obj.getClass() )
115         {
116             return false;
117         }
118         DependencyCoordinate other = (DependencyCoordinate) obj;
119         if ( artifactId == null )
120         {
121             if ( other.artifactId != null )
122             {
123                 return false;
124             }
125         }
126         else if ( !artifactId.equals( other.artifactId ) )
127         {
128             return false;
129         }
130         if ( classifier == null )
131         {
132             if ( other.classifier != null )
133             {
134                 return false;
135             }
136         }
137         else if ( !classifier.equals( other.classifier ) )
138         {
139             return false;
140         }
141         if ( groupId == null )
142         {
143             if ( other.groupId != null )
144             {
145                 return false;
146             }
147         }
148         else if ( !groupId.equals( other.groupId ) )
149         {
150             return false;
151         }
152         if ( type == null )
153         {
154             if ( other.type != null )
155             {
156                 return false;
157             }
158         }
159         else if ( !type.equals( other.type ) )
160         {
161             return false;
162         }
163         if ( version == null )
164         {
165             if ( other.version != null )
166             {
167                 return false;
168             }
169         }
170         else if ( !version.equals( other.version ) )
171         {
172             return false;
173         }
174         return true;
175     }
176 
177     @Override
178     public String toString()
179     {
180         return groupId + ":" + artifactId + ( version != null ? ":" + version : "" )
181             + ( classifier != null ? ":" + classifier : "" ) + ( type != null ? "." + type : "" );
182     }
183 }