1 package org.codehaus.mojo.exec;
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 import org.apache.maven.artifact.Artifact;
23
24 /**
25 * <p>
26 * ExecutableDependency class.
27 * </p>
28 */
29 public class ExecutableDependency
30 {
31 private String groupId;
32
33 private String artifactId;
34
35 /**
36 * <p>
37 * Getter for the field <code>groupId</code>.
38 * </p>
39 *
40 * @return a {@link java.lang.String} object.
41 */
42 public String getGroupId()
43 {
44 return this.groupId;
45 }
46
47 /**
48 * <p>
49 * Setter for the field <code>groupId</code>.
50 * </p>
51 *
52 * @param groupId a {@link java.lang.String} object.
53 */
54 public void setGroupId( String groupId )
55 {
56 this.groupId = groupId;
57 }
58
59 /**
60 * <p>
61 * Getter for the field <code>artifactId</code>.
62 * </p>
63 *
64 * @return a {@link java.lang.String} object.
65 */
66 public String getArtifactId()
67 {
68 return this.artifactId;
69 }
70
71 /**
72 * <p>
73 * Setter for the field <code>artifactId</code>.
74 * </p>
75 *
76 * @param artifactId a {@link java.lang.String} object.
77 */
78 public void setArtifactId( String artifactId )
79 {
80 this.artifactId = artifactId;
81 }
82
83 /**
84 * <p>
85 * Matches the groupId and artifactId.
86 * </p>
87 *
88 * @param artifact a {@link org.apache.maven.artifact.Artifact} object.
89 * @return <code>true</code> if both math, <code>false</code> otherwise.
90 */
91 public boolean matches( Artifact artifact )
92 {
93 return artifact.getGroupId().equals( this.getGroupId() )
94 && artifact.getArtifactId().equals( this.getArtifactId() );
95 }
96
97 /** {@inheritDoc} */
98 public String toString()
99 {
100 return this.groupId + ":" + this.artifactId;
101 }
102
103 /** {@inheritDoc} */
104 public boolean equals( Object o )
105 {
106 if ( this == o )
107 {
108 return true;
109 }
110 if ( !( o instanceof ExecutableDependency ) )
111 {
112 return false;
113 }
114
115 final ExecutableDependency that = (ExecutableDependency) o;
116
117 if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null )
118 {
119 return false;
120 }
121 if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null )
122 {
123 return false;
124 }
125
126 return true;
127 }
128
129 /** {@inheritDoc} */
130 public int hashCode()
131 {
132 int result;
133 result = ( groupId != null ? groupId.hashCode() : 0 );
134 result = 29 * result + ( artifactId != null ? artifactId.hashCode() : 0 );
135 return result;
136 }
137 }