se.vandmo.dependencylock.maven.Artifacts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-lock-maven-plugin Show documentation
Show all versions of dependency-lock-maven-plugin Show documentation
Maven plugin that makes sure that Maven dependency are not accidentaly changed.
package se.vandmo.dependencylock.maven;
import static java.util.Collections.sort;
import static java.util.Collections.unmodifiableList;
import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public final class Artifacts {
public final List artifacts;
Artifacts(List artifacts) {
ArrayList copy = new ArrayList<>(artifacts);
sort(copy);
this.artifacts = unmodifiableList(copy);
}
public static Artifacts from(Set artifacts) {
return new Artifacts(artifacts.stream().map(Artifact::from).collect(toList()));
}
public Optional by(ArtifactIdentifier identifier) {
for (Artifact artifact : artifacts) {
if (identifier.equals(artifact.identifier)) {
return Optional.of(artifact);
}
}
return Optional.empty();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy