KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > maven > PluginName


1 package hudson.maven;
2
3 import org.apache.maven.plugin.descriptor.PluginDescriptor;
4
5 /**
6  * Identifier of a specific version of a Maven plugin
7  * that consists of groupId, artifactId, and version.
8  *
9  * @author Kohsuke Kawaguchi
10  */

11 public final class PluginName {
12     public final String JavaDoc groupId;
13     public final String JavaDoc artifactId;
14     public final String JavaDoc version;
15
16     public PluginName(String JavaDoc groupId, String JavaDoc artifactId, String JavaDoc version) {
17         this.groupId = groupId;
18         this.artifactId = artifactId;
19         this.version = version;
20     }
21
22     public PluginName(PluginDescriptor pd) {
23         this(pd.getGroupId(), pd.getArtifactId(), pd.getVersion());
24     }
25
26     /**
27      * Returns the "groupId:artifactId:version" form.
28      */

29     public String JavaDoc toString() {
30         return groupId+':'+artifactId+':'+version;
31     }
32
33     public boolean equals(Object JavaDoc o) {
34         if (this == o) return true;
35         if (o == null || getClass() != o.getClass()) return false;
36
37         PluginName that = (PluginName) o;
38
39         return artifactId.equals(that.artifactId)
40             && groupId.equals(that.groupId)
41             && version.equals(that.version);
42
43     }
44
45     public int hashCode() {
46         int result;
47         result = groupId.hashCode();
48         result = 31 * result + artifactId.hashCode();
49         result = 31 * result + version.hashCode();
50         return result;
51     }
52
53     public boolean matches(String JavaDoc groupId, String JavaDoc artifactId) {
54         return this.groupId.equals(groupId) && this.artifactId.equals(artifactId);
55     }
56 }
57
Popular Tags