use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class PluginVersionConstraintChecker method checkConstraints.
@Override
public Set<ConstraintCheckResult> checkConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<ConstraintCheckResult> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof PluginVersionConstraint) {
final PluginVersionConstraint versionConstraint = (PluginVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
boolean result = false;
for (Semver pluginVersion : pluginVersions) {
if (requiredVersion.isSatisfiedBy(pluginVersion)) {
result = true;
}
}
ConstraintCheckResult constraintCheckResult = ConstraintCheckResult.create(versionConstraint, result);
fulfilledConstraints.add(constraintCheckResult);
}
}
return fulfilledConstraints.build();
}
use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class GraylogVersionConstraintChecker method ensureConstraints.
@Override
public Set<Constraint> ensureConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<Constraint> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof GraylogVersionConstraint) {
final GraylogVersionConstraint versionConstraint = (GraylogVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
if (requiredVersion.isSatisfiedBy(graylogVersion.withClearedSuffixAndBuild())) {
fulfilledConstraints.add(constraint);
}
}
}
return fulfilledConstraints.build();
}
use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class PluginVersionConstraint method of.
public static PluginVersionConstraint of(PluginMetaData pluginMetaData) {
final Version version = pluginMetaData.getVersion();
final String versionString = version.toString().replace("-SNAPSHOT", "");
final Requirement requirement = Requirement.buildNPM(">=" + versionString);
return builder().pluginId(pluginMetaData.getUniqueId()).version(requirement).build();
}
use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class GraylogVersionConstraint method of.
public static GraylogVersionConstraint of(Version version) {
final String versionString = version.toString().replace("-SNAPSHOT", "");
final Requirement requirement = Requirement.buildNPM(">=" + versionString);
return builder().version(requirement).build();
}
use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class SemverRequirementDeserializerTest method successfullyDeserializesString.
@Test
public void successfullyDeserializesString() throws IOException {
final Requirement requirement = objectMapper.readValue("\"^1.3.7-rc.2+build.2.b8f12d7\"", Requirement.class);
assertThat(requirement).isEqualTo(Requirement.buildNPM("^1.3.7-rc.2+build.2.b8f12d7"));
}
Aggregations