io.featurehub.strategies.matchers.IpAddressArrayMatcher 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;
import java.net.InetAddress;
public class IpAddressArrayMatcher implements StrategyMatcher {
@Override
public boolean match(String suppliedValue, FeatureRolloutStrategyAttribute attr) {
try {
InetAddress suppliedAddress = io.featurehub.strategies.matchers.CIDRMatch.suppliedAddress(suppliedValue);
switch(attr.getConditional()) {
case EQUALS:
case INCLUDES:
return attr.getValues().stream().anyMatch(val -> io.featurehub.strategies.matchers.CIDRMatch.cidrMatch(val.toString(), suppliedAddress));
case ENDS_WITH:
break;
case STARTS_WITH:
break;
case GREATER:
break;
case GREATER_EQUALS:
break;
case LESS:
break;
case LESS_EQUALS:
break;
case NOT_EQUALS:
case EXCLUDES:
return attr.getValues().stream().noneMatch(val -> CIDRMatch.cidrMatch(val.toString(), suppliedAddress));
case REGEX:
break;
}
} catch (Exception ignored) {
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy