io.github.chains_project.maven_lockfile.data.ArtifactId Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-lockfile Show documentation
Show all versions of maven-lockfile Show documentation
This plugin is a state-of-the-art solution that can be used to validate the integrity
of a maven repository.
It does this by generating a lock file that contains the checksums of all the artifacts in the
repository.
The lock file can then be used to validate the integrity of the repository.
This guards the supply chain against malicious actors that might tamper with the artifacts in
the repository.
The newest version!
package io.github.chains_project.maven_lockfile.data;
import com.google.common.base.Strings;
import java.util.Objects;
/**
* This class represents an artifact id.
* An artifact id is an identifier for a maven artifact, and is unique within a group id.
* It is a string that is not null or empty. It is immutable.
* It is used to identify a maven artifact in a lock file.
* It is also used to identify a maven artifact in a dependency graph.
* For example, the artifact id of the artifact "org.apache.commons:commons-lang3:3.9" is "commons-lang3".
*/
public class ArtifactId implements Comparable {
public static ArtifactId of(String artifactId) {
// Artifact ID must be non-null and non-empty.
String checked = Objects.requireNonNull(artifactId);
if (Strings.isNullOrEmpty(checked)) {
throw new IllegalArgumentException("artifactId cannot be empty");
}
return new ArtifactId(artifactId);
}
private final String value;
public ArtifactId(String artifactId) {
this.value = Objects.requireNonNull(artifactId);
}
public String getValue() {
return value;
}
@Override
public String toString() {
return "{" + " ArtifactId='" + getValue() + "'" + "}";
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ArtifactId)) {
return false;
}
ArtifactId artifactId = (ArtifactId) o;
return Objects.equals(value, artifactId.value);
}
@Override
public int hashCode() {
return Objects.hashCode(value);
}
@Override
public int compareTo(ArtifactId o) {
return this.value.compareTo(o.value);
}
}