File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\maven-plugin\src\main\java\hudson\maven\PluginName.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.maven;
25
26 import org.apache.maven.plugin.descriptor.PluginDescriptor;
27
28 /**
29 * Identifier of a specific version of a Maven plugin
30 * that consists of groupId, artifactId, and version.
31 *
32 * @author Kohsuke Kawaguchi
33 */
34 public final class PluginName {
35 public final String groupId;
36 public final String artifactId;
37 public final String version;
38
39 public PluginName(String groupId, String artifactId, String version) {
40 this.groupId = groupId;
41 this.artifactId = artifactId;
42 this.version = version;
43 }
44
45 public PluginName(PluginDescriptor pd) {
46 this(pd.getGroupId(), pd.getArtifactId(), pd.getVersion());
47 }
48
49 /**
50 * Returns the "groupId:artifactId:version" form.
51 */
52 public String toString() {
53 return groupId+':'+artifactId+':'+version;
54 }
55
56 public boolean equals(Object o) {
57 if (this == o) return true;
58 if (o == null || getClass() != o.getClass()) return false;
59
60 PluginName that = (PluginName) o;
61
62 return artifactId.equals(that.artifactId)
63 && groupId.equals(that.groupId)
64 && version.equals(that.version);
65
66 }
67
68 public int hashCode() {
69 int result;
70 result = groupId.hashCode();
71 result = 31 * result + artifactId.hashCode();
72 result = 31 * result + version.hashCode();
73 return result;
74 }
75
76 public boolean matches(String groupId, String artifactId) {
77 return this.groupId.equals(groupId) && this.artifactId.equals(artifactId);
78 }
79 }
80