Remove unused code from RuleSetUtils
@@ -92,43 +92,21 @@ public class RuleSetUtils {
*/
public static class HasAttributes implements Predicate<RuleClass> {
- private enum Operator {
- ANY, ALL
- }
-
private final List<Pair<String, Type<?>>> attributes;
- private final Operator operator;
- public HasAttributes(Collection<Pair<String, Type<?>>> attributes, Operator operator) {
+ public HasAttributes(Collection<Pair<String, Type<?>>> attributes) {
this.attributes = ImmutableList.copyOf(attributes);
- this.operator = operator;
}
@Override
- public boolean apply(final RuleClass input) {
- switch (operator) {
- case ANY:
- for (Pair<String, Type<?>> attribute : attributes) {
- if (input.hasAttr(attribute.first, attribute.second)) {
- return true;
- }
- }
- return false;
- case ALL:
- for (Pair<String, Type<?>> attribute : attributes) {
- if (!input.hasAttr(attribute.first, attribute.second)) {
- return false;
- }
- }
- return true;
- }
- return false;
+ public boolean apply(final RuleClass ruleClass) {
+ return attributes.stream().anyMatch(pair -> ruleClass.hasAttr(pair.first, pair.second));
}
}
public static Predicate<RuleClass> hasAnyAttributes(
Collection<Pair<String, Type<?>>> attributes) {
- return new HasAttributes(attributes, HasAttributes.Operator.ANY);
+ return new HasAttributes(attributes);
}
/**
