Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2be4d631254ced2e5914638d18cfa82d3f4f9e6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
 * Copyright (c) 2010 Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *      Sonatype, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.m2e.core.project.configurator;

import org.apache.maven.plugin.MojoExecution;


public class MojoExecutionKey {
  private final MojoExecution mojoExecution;

  public MojoExecutionKey(MojoExecution mojoExecution) {
    this.mojoExecution = mojoExecution;
  }

  public MojoExecution getMojoExecution() {
    return mojoExecution;
  }

  public int hashCode() {
    int hash = mojoExecution.getGroupId().hashCode();
    hash = 17 * hash + mojoExecution.getArtifactId().hashCode();
    hash = 17 * hash + mojoExecution.getVersion().hashCode();
    hash = 17 * mojoExecution.getGoal().hashCode();
    if(mojoExecution.getExecutionId() != null) {
      hash = 17 * mojoExecution.getExecutionId().hashCode();
    }
    return hash;
  }

  public boolean equals(Object obj) {
    if(this == obj) {
      return true;
    }
    if(!(obj instanceof MojoExecutionKey)) {
      return false;
    }

    MojoExecutionKey other = (MojoExecutionKey) obj;

    boolean equals = mojoExecution.getGroupId().equals(other.mojoExecution.getGroupId())
        && mojoExecution.getArtifactId().equals(other.mojoExecution.getArtifactId())
        && mojoExecution.getVersion().equals(other.mojoExecution.getVersion())
        && mojoExecution.getGoal().equals(other.mojoExecution.getGoal());
    if(!equals) {
      return false;
    }

    if(mojoExecution.getExecutionId() == null) {
      return other.mojoExecution.getExecutionId() == null;
    }
    return mojoExecution.getExecutionId().equals(other.mojoExecution.getExecutionId());
  }

  public String getKeyString() {
    return mojoExecution.getGroupId() + ":" + mojoExecution.getArtifactId() + ":" + mojoExecution.getVersion() + ":"
        + mojoExecution.getGoal() + ":" + mojoExecution.getExecutionId();
  }
}

Back to the top