View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugin.compiler;
20  
21  import java.util.Objects;
22  import java.util.Set;
23  
24  /**
25   * Simple representation of Maven-coordinates of a dependency.
26   *
27   * @author Andreas Gudian
28   * @since 3.4
29   */
30  public class DependencyCoordinate {
31      private String groupId;
32  
33      private String artifactId;
34  
35      private String version;
36  
37      private String classifier;
38  
39      private String type = "jar";
40  
41      private Set<DependencyExclusion> exclusions;
42  
43      public String getGroupId() {
44          return groupId;
45      }
46  
47      public void setGroupId(String groupId) {
48          this.groupId = groupId;
49      }
50  
51      public String getArtifactId() {
52          return artifactId;
53      }
54  
55      public void setArtifactId(String artifactId) {
56          this.artifactId = artifactId;
57      }
58  
59      public String getVersion() {
60          return version;
61      }
62  
63      public void setVersion(String version) {
64          this.version = version;
65      }
66  
67      public String getClassifier() {
68          return classifier;
69      }
70  
71      public void setClassifier(String classifier) {
72          this.classifier = classifier;
73      }
74  
75      public String getType() {
76          return type;
77      }
78  
79      public void setType(String type) {
80          this.type = type;
81      }
82  
83      public Set<DependencyExclusion> getExclusions() {
84          return exclusions;
85      }
86  
87      public void setExclusions(Set<DependencyExclusion> exclusions) {
88          this.exclusions = exclusions;
89      }
90  
91      @Override
92      public int hashCode() {
93          return Objects.hash(groupId, artifactId, version, classifier, type, exclusions);
94      }
95  
96      @Override
97      public boolean equals(Object obj) {
98          if (this == obj) {
99              return true;
100         }
101         if (obj == null) {
102             return false;
103         }
104         if (getClass() != obj.getClass()) {
105             return false;
106         }
107         DependencyCoordinate other = (DependencyCoordinate) obj;
108         return Objects.equals(groupId, other.groupId)
109                 && Objects.equals(artifactId, other.artifactId)
110                 && Objects.equals(version, other.version)
111                 && Objects.equals(classifier, other.classifier)
112                 && Objects.equals(type, other.type)
113                 && Objects.equals(exclusions, other.exclusions);
114     }
115 
116     @Override
117     public String toString() {
118         return groupId + ":" + artifactId + (version != null ? ":" + version : "")
119                 + (classifier != null ? ":" + classifier : "") + (type != null ? "." + type : "");
120     }
121 }