io.featurehub.strategies.matchers.SemanticVersionArrayMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client-core Show documentation
Show all versions of java-client-core Show documentation
Shared core of featurehub client.
package io.featurehub.strategies.matchers;
import io.featurehub.sse.model.FeatureRolloutStrategyAttribute;
public class SemanticVersionArrayMatcher implements StrategyMatcher {
@Override
public boolean match(String suppliedValue, FeatureRolloutStrategyAttribute attr) {
final SemanticVersionComparable suppliedVersion = new SemanticVersionComparable(suppliedValue);
switch (attr.getConditional()) {
case EQUALS:
case INCLUDES:
return attr.getValues().stream().anyMatch(v -> suppliedVersion.equals(new SemanticVersionComparable(v.toString())));
case ENDS_WITH:
break;
case STARTS_WITH:
break;
case GREATER:
return attr.getValues().stream().anyMatch(v -> suppliedVersion.compareTo(new SemanticVersionComparable(v.toString())) > 0);
case GREATER_EQUALS:
return attr.getValues().stream().anyMatch(v -> suppliedVersion.compareTo(new SemanticVersionComparable(v.toString())) >= 0);
case LESS:
return attr.getValues().stream().anyMatch(v -> suppliedVersion.compareTo(new SemanticVersionComparable(v.toString())) < 0);
case LESS_EQUALS:
return attr.getValues().stream().anyMatch(v -> suppliedVersion.compareTo(new SemanticVersionComparable(v.toString())) <= 0);
case NOT_EQUALS:
case EXCLUDES:
return attr.getValues().stream().noneMatch(v -> suppliedVersion.equals(new SemanticVersionComparable(v.toString())));
case REGEX:
break;
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy