View Javadoc
1   package com.soebes.maven.extensions;
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   * @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
24   */
25  class ProjectKey
26  {
27      private final String groupId;
28  
29      private final String artifactId;
30  
31      private final String version;
32  
33      public ProjectKey( final String groupId, final String artifactId, final String version )
34      {
35          super();
36          this.groupId = groupId;
37          this.artifactId = artifactId;
38          this.version = version;
39      }
40  
41      public String getGroupId()
42      {
43          return groupId;
44      }
45  
46      public String getArtifactId()
47      {
48          return artifactId;
49      }
50  
51      public String getVersion()
52      {
53          return version;
54      }
55  
56      public String getId()
57      {
58          return this.groupId + ":" + this.artifactId + ":" + this.version;
59      }
60  
61      public int hashCode()
62      {
63          final int prime = 31;
64          int result = 1;
65          result = prime * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() );
66          result = prime * result + ( ( groupId == null ) ? 0 : groupId.hashCode() );
67          result = prime * result + ( ( version == null ) ? 0 : version.hashCode() );
68          return result;
69      }
70  
71      public boolean equals( Object obj )
72      {
73          if ( this == obj )
74              return true;
75          if ( obj == null )
76              return false;
77          if ( !( obj instanceof ProjectKey ) )
78              return false;
79          ProjectKey other = (ProjectKey) obj;
80          if ( artifactId == null )
81          {
82              if ( other.artifactId != null )
83                  return false;
84          }
85          else if ( !artifactId.equals( other.artifactId ) )
86              return false;
87          if ( groupId == null )
88          {
89              if ( other.groupId != null )
90                  return false;
91          }
92          else if ( !groupId.equals( other.groupId ) )
93              return false;
94          if ( version == null )
95          {
96              if ( other.version != null )
97                  return false;
98          }
99          else if ( !version.equals( other.version ) )
100             return false;
101         return true;
102     }
103 
104 }