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