KiePMMLSimpleSetPredicate extends KiePMMLPredicate { protected boolean evaluation(Object rawValue) { String stringValue = (String) ConverterTypeUtil.convert(String.class, rawValue); Object convertedValue = arrayType.getValue(stringValue); switch (inNotIn) { case IN: return values.contains(convertedValue); case NOT_IN: return !values.contains(convertedValue); default: throw new KiePMMLException("Unknown IN_NOTIN" + inNotIn); } } protected  KiePMMLSimpleSetPredicate(final String name, final List<KiePMMLExtension> extensions, final ARRAY_TYPE arrayType, final IN_NOTIN inNotIn); static Builder builder(final String name, final List<KiePMMLExtension> extensions, final ARRAY_TYPE arrayType, final IN_NOTIN inNotIn); @Override boolean evaluate(Map<String, Object> values); @Override String getName(); List<Object> getValues(); ARRAY_TYPE getArrayType(); IN_NOTIN getInNotIn(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void evaluationStringIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.STRING; List<Object> values = getObjects(arrayType, 1); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN); assertFalse(kiePMMLSimpleSetPredicate.evaluation("NOT")); assertTrue(kiePMMLSimpleSetPredicate.evaluation(values.get(0))); }
@Test public void evaluationStringNotIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.STRING; List<Object> values = getObjects(arrayType, 1); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN); assertFalse(kiePMMLSimpleSetPredicate.evaluation(values.get(0))); assertTrue(kiePMMLSimpleSetPredicate.evaluation("NOT")); }
@Test public void evaluationIntIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.INT; List<Object> values = getObjects(arrayType, 1); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN); assertFalse(kiePMMLSimpleSetPredicate.evaluation("234")); assertTrue(kiePMMLSimpleSetPredicate.evaluation(values.get(0))); }
@Test public void evaluationIntNotIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.INT; List<Object> values = getObjects(arrayType, 1); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN); assertFalse(kiePMMLSimpleSetPredicate.evaluation(values.get(0))); assertTrue(kiePMMLSimpleSetPredicate.evaluation("234")); }
@Test public void evaluationRealIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.REAL; List<Object> values = getObjects(arrayType, 1); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN); assertFalse(kiePMMLSimpleSetPredicate.evaluation("23.4")); assertTrue(kiePMMLSimpleSetPredicate.evaluation(values.get(0))); }
@Test public void evaluationRealNotIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.REAL; List<Object> values = getObjects(arrayType, 1); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN); assertFalse(kiePMMLSimpleSetPredicate.evaluation(values.get(0))); assertTrue(kiePMMLSimpleSetPredicate.evaluation("23.4")); }