All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.itemis.maven.aether.ArtifactCoordinates Maven / Gradle / Ivy

Go to download

This plugin provides a generic alternative to the error-prone default release plugin provided by Maven. It is designed to require a minimal effort of work for releasing modules and being extensible to integrate in every project setup.

There is a newer version: 2.10.0
Show newest version
package com.itemis.maven.aether;

import com.google.common.base.Objects;

/**
 * Coordinates that identify an artifact uniquely. Coordinates are f.i. used in aether repositories.
 *
 * @author Stanley Hillner
 * @since 1.0.0
 */
public class ArtifactCoordinates {
  private String groupId;
  private String artifactId;
  private String version;
  private String type;
  private String classifier;

  public ArtifactCoordinates(String groupId, String artifactId, String version) {
    this(groupId, artifactId, version, null, null);
  }

  public ArtifactCoordinates(String groupId, String artifactId, String version, String type) {
    this(groupId, artifactId, version, type, null);
  }

  public ArtifactCoordinates(String groupId, String artifactId, String version, String type, String classifier) {
    this.groupId = groupId;
    this.artifactId = artifactId;
    this.version = version;
    this.type = type;
    this.classifier = classifier;
  }

  public String getGroupId() {
    return this.groupId;
  }

  public String getArtifactId() {
    return this.artifactId;
  }

  public String getVersion() {
    return this.version;
  }

  public String getType() {
    return this.type;
  }

  public String getClassifier() {
    return this.classifier;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(this.groupId).append(':');
    sb.append(this.artifactId).append(':');
    if (this.type != null) {
      sb.append(this.type).append(':');
    }
    if (this.classifier != null) {
      sb.append(this.classifier).append(':');
    }
    sb.append(this.version);
    return sb.toString();
  }

  @Override
  public boolean equals(Object other) {
    if (other == null) {
      return false;
    }
    if (!(other instanceof ArtifactCoordinates)) {
      return false;
    }
    return Objects.equal(toString(), other.toString());
  }

  public boolean equalsGAV(Object other) {
    if (other == null) {
      return false;
    }
    if (!(other instanceof ArtifactCoordinates)) {
      return false;
    }

    ArtifactCoordinates otherCoordinates = (ArtifactCoordinates) other;
    return Objects.equal(getArtifactId(), otherCoordinates.getArtifactId())
        && Objects.equal(getGroupId(), otherCoordinates.getGroupId())
        && Objects.equal(getVersion(), otherCoordinates.getVersion());
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(this.groupId, this.artifactId, this.type, this.classifier, this.version);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy