Search in sources :

Example 6 with GraylogVersionConstraint

use of org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint in project graylog2-server by Graylog2.

the class GraylogVersionConstraintChecker method checkConstraints.

@Override
public Set<ConstraintCheckResult> checkConstraints(Collection<Constraint> requestedConstraints) {
    final ImmutableSet.Builder<ConstraintCheckResult> fulfilledConstraints = ImmutableSet.builder();
    for (Constraint constraint : requestedConstraints) {
        if (constraint instanceof GraylogVersionConstraint) {
            final GraylogVersionConstraint versionConstraint = (GraylogVersionConstraint) constraint;
            final Requirement requiredVersion = versionConstraint.version();
            final ConstraintCheckResult constraintCheckResult = ConstraintCheckResult.create(versionConstraint, requiredVersion.isSatisfiedBy(graylogVersion.withClearedSuffixAndBuild()));
            fulfilledConstraints.add(constraintCheckResult);
        }
    }
    return fulfilledConstraints.build();
}
Also used : ConstraintCheckResult(org.graylog2.contentpacks.model.constraints.ConstraintCheckResult) Requirement(com.vdurmont.semver4j.Requirement) ImmutableSet(com.google.common.collect.ImmutableSet) GraylogVersionConstraint(org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint) Constraint(org.graylog2.contentpacks.model.constraints.Constraint) GraylogVersionConstraint(org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint)

Aggregations

Constraint (org.graylog2.contentpacks.model.constraints.Constraint)6 GraylogVersionConstraint (org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint)6 PluginVersionConstraint (org.graylog2.contentpacks.model.constraints.PluginVersionConstraint)4 Test (org.junit.Test)4 ConstraintCheckResult (org.graylog2.contentpacks.model.constraints.ConstraintCheckResult)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Requirement (com.vdurmont.semver4j.Requirement)2