PredicateUtil { static public Boolean evaluateSimpleSetPredicate(SimpleSetPredicate simpleSetPredicate, EvaluationContext context){ FieldName name = simpleSetPredicate.getField(); if(name == null){ throw new MissingAttributeException(simpleSetPredicate, PMMLAttributes.SIMPLESETPREDICATE_FIELD); } SimpleSetPredicate.BooleanOperator booleanOperator = simpleSetPredicate.getBooleanOperator(); if(booleanOperator == null){ throw new MissingAttributeException(simpleSetPredicate, PMMLAttributes.SIMPLESETPREDICATE_BOOLEANOPERATOR); } FieldValue value = context.evaluate(name); if(FieldValueUtil.isMissing(value)){ return null; } Array array = simpleSetPredicate.getArray(); if(array == null){ throw new MissingElementException(simpleSetPredicate, PMMLElements.SIMPLESETPREDICATE_ARRAY); } switch(booleanOperator){ case IS_IN: return value.isIn(simpleSetPredicate); case IS_NOT_IN: return !value.isIn(simpleSetPredicate); default: throw new UnsupportedAttributeException(simpleSetPredicate, booleanOperator); } } private  PredicateUtil(); static Predicate ensurePredicate(E hasPredicate); static Boolean evaluatePredicateContainer(E hasPredicate, EvaluationContext context); static Boolean evaluate(Predicate predicate, EvaluationContext context); static Boolean evaluateSimplePredicate(SimplePredicate simplePredicate, EvaluationContext context); static Boolean evaluateSimpleSetPredicate(SimpleSetPredicate simpleSetPredicate, EvaluationContext context); static Boolean evaluateCompoundPredicate(CompoundPredicate compoundPredicate, EvaluationContext context); static CompoundPredicateResult evaluateCompoundPredicateInternal(CompoundPredicate compoundPredicate, EvaluationContext context); static Boolean evaluateTrue(True truePredicate); static Boolean evaluateFalse(False falsePredicate); static Boolean evaluateJavaPredicate(JavaPredicate javaPredicate, EvaluationContext context); static Boolean binaryAnd(Boolean left, Boolean right); static Boolean binaryOr(Boolean left, Boolean right); static Boolean binaryXor(Boolean left, Boolean right);  }
@Test public void evaluateSimpleSetPredicate(){ FieldName fruit = FieldName.create("fruit"); SimpleSetPredicate simpleSetPredicate = new SimpleSetPredicate(fruit, SimpleSetPredicate.BooleanOperator.IS_IN, new Array(Array.Type.STRING, "apple orange")); assertEquals(null, evaluate(simpleSetPredicate, fruit, null)); assertEquals(Boolean.TRUE, evaluate(simpleSetPredicate, fruit, "apple")); assertEquals(Boolean.FALSE, evaluate(simpleSetPredicate, fruit, "pineapple")); simpleSetPredicate.setBooleanOperator(SimpleSetPredicate.BooleanOperator.IS_NOT_IN); assertEquals(Boolean.FALSE, evaluate(simpleSetPredicate, fruit, "apple")); assertEquals(Boolean.TRUE, evaluate(simpleSetPredicate, fruit, "pineapple")); }