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 ProjectGoal
26  {
27      private final ProjectKey project;
28  
29      private final GoalKey mojo;
30  
31      public ProjectGoal( ProjectKey project, GoalKey mojo )
32      {
33          super();
34          this.project = project;
35          this.mojo = mojo;
36      }
37  
38      public ProjectKey getProject()
39      {
40          return project;
41      }
42  
43      public GoalKey getMojo()
44      {
45          return mojo;
46      }
47  
48      @Override
49      public final int hashCode()
50      {
51          final int prime = 31;
52          int result = 1;
53          result = prime * result + ( ( mojo == null ) ? 0 : mojo.hashCode() );
54          result = prime * result + ( ( project == null ) ? 0 : project.hashCode() );
55          return result;
56      }
57  
58      public String getId()
59      {
60          return getMojo().getGroupId() + ":" + getMojo().getArtifactId() + ":" + getMojo().getVersion() + ":"
61              + getMojo().getGoal() + " (" + getMojo().getExecutionId() + ")";
62      }
63  
64      @Override
65      public final boolean equals( Object obj )
66      {
67          if ( this == obj )
68          {
69              return true;
70          }
71          if ( obj == null )
72          {
73              return false;
74          }
75          if ( !( obj instanceof ProjectGoal ) )
76          {
77              return false;
78          }
79          ProjectGoal other = (ProjectGoal) obj;
80          if ( mojo == null )
81          {
82              if ( other.mojo != null )
83              {
84                  return false;
85              }
86          }
87          else if ( !mojo.equals( other.mojo ) )
88          {
89              return false;
90          }
91          if ( project == null )
92          {
93              if ( other.project != null )
94              {
95                  return false;
96              }
97          }
98          else if ( !project.equals( other.project ) )
99          {
100             return false;
101         }
102         return true;
103     }
104 
105 }