@Test public void evaluateSurrogateCompoundPredicate(){ FieldName temperature = FieldName.create("temperature"); FieldName humidity = FieldName.create("humidity"); CompoundPredicate temperaturePredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.AND, null) .addPredicates( new SimplePredicate(temperature, SimplePredicate.Operator.LESS_THAN, "90"), new SimplePredicate(temperature, SimplePredicate.Operator.GREATER_THAN, "50") ); SimplePredicate humidityPredicate = new SimplePredicate(humidity, SimplePredicate.Operator.GREATER_OR_EQUAL, "80"); CompoundPredicate compoundPredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.SURROGATE, null) .addPredicates(temperaturePredicate, humidityPredicate); assertEquals(Boolean.TRUE, evaluate(compoundPredicate, temperature, 70, humidity, null)); assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, 40, humidity, null)); assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, 100, humidity, null)); assertEquals(Boolean.TRUE, evaluate(compoundPredicate, temperature, null, humidity, 90)); assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, null, humidity, 70)); assertEquals(null, evaluate(compoundPredicate, temperature, null, humidity, null)); }
static public Boolean evaluate(Predicate predicate, EvaluationContext context){ try { return evaluatePredicate(predicate, context); } catch(PMMLException pe){ throw pe.ensureContext(predicate); } }
PredicateUtil { static public Boolean evaluate(Predicate predicate, EvaluationContext context){ try { return evaluatePredicate(predicate, context); } catch(PMMLException pe){ throw pe.ensureContext(predicate); } } }
PredicateUtil { static public Boolean evaluate(Predicate predicate, EvaluationContext context){ try { return evaluatePredicate(predicate, context); } catch(PMMLException pe){ throw pe.ensureContext(predicate); } } private  PredicateUtil(); }
PredicateUtil { static public Boolean evaluate(Predicate predicate, EvaluationContext context){ try { return evaluatePredicate(predicate, context); } catch(PMMLException pe){ throw pe.ensureContext(predicate); } } 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); }
PredicateUtil { static public Boolean evaluate(Predicate predicate, EvaluationContext context){ try { return evaluatePredicate(predicate, context); } catch(PMMLException pe){ throw pe.ensureContext(predicate); } } 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);  }