io.github.chains_project.maven_lockfile.data.Classifier 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;
/**
* A Maven artifact classifier is an optional and arbitrary string that gets appended to the generated artifact's name just after its version
* see https://www.baeldung.com/maven-artifact-classifiers
*/
public class Classifier implements Comparable {
public static Classifier of(String classifier) {
if (Strings.isNullOrEmpty(classifier)) {
return null;
}
return new Classifier(classifier);
}
private final String value;
private Classifier(String classifier) {
this.value = Objects.requireNonNull(classifier, "classifier is marked non-null but is null");
}
public String getValue() {
return value;
}
@Override
public String toString() {
return "{" + " Classifier='" + getValue() + "'" + "}";
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof Classifier)) {
return false;
}
Classifier classifier = (Classifier) o;
return Objects.equals(value, classifier.value);
}
@Override
public int hashCode() {
return Objects.hashCode(value);
}
@Override
public int compareTo(Classifier o) {
return this.value.compareTo(o.value);
}
}