KiePMMLASTFactoryUtils { public static List<KiePMMLFieldOperatorValue> getXORConstraintEntryFromSimplePredicates(final List<Predicate> predicates, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { return predicates.stream() .filter(predicate -> predicate instanceof SimplePredicate) .map(predicate -> { SimplePredicate simplePredicate = (SimplePredicate) predicate; String fieldName = fieldTypeMap.get(simplePredicate.getField().getValue()).getGeneratedType(); OPERATOR operator = OPERATOR.byName(simplePredicate.getOperator().value()); Object value = getCorrectlyFormattedObject(simplePredicate, fieldTypeMap); return new KiePMMLFieldOperatorValue(fieldName, null, Collections.singletonList(new KiePMMLOperatorValue(operator, value)), null); }).collect(Collectors.toList()); } private  KiePMMLASTFactoryUtils(); static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromAndOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromXOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static KiePMMLFieldOperatorValue getConstraintEntryFromSimplePredicates(final String fieldName,
                                                                                   final BOOLEAN_OPERATOR containerOperator,
                                                                                   final List<SimplePredicate> simplePredicates,
                                                                                   final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static List<KiePMMLFieldOperatorValue> getXORConstraintEntryFromSimplePredicates(final List<Predicate> predicates, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static Object getCorrectlyFormattedObject(final SimplePredicate simplePredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap);  }
@Test public void getXORConstraintEntryFromSimplePredicates() { List<Predicate> predicates = new ArrayList<>(simplePredicates); List<KiePMMLFieldOperatorValue> retrieved = KiePMMLASTFactoryUtils .getXORConstraintEntryFromSimplePredicates(predicates, fieldTypeMap); assertNotNull(retrieved); assertEquals(simplePredicates.size(), retrieved.size()); commonVerifyKiePMMLFieldOperatorValueList(retrieved, null); }