@Test public void getConstraintEntriesFromXOrCompoundPredicate() { CompoundPredicate compoundPredicate = new CompoundPredicate(); compoundPredicate.setBooleanOperator(CompoundPredicate.BooleanOperator.XOR); List<Predicate> predicates = IntStream.range(0, 2).mapToObj(index -> simplePredicates.get(index)).collect(Collectors.toList()); compoundPredicate.getPredicates().addAll(predicates); List<KiePMMLFieldOperatorValue> retrieved = KiePMMLASTFactoryUtils .getConstraintEntriesFromXOrCompoundPredicate(compoundPredicate, fieldTypeMap); assertNotNull(retrieved); assertEquals(predicates.size(), retrieved.size()); commonVerifyKiePMMLFieldOperatorValueList(retrieved, null); }
public static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromXOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { if (!CompoundPredicate.BooleanOperator.XOR.equals(compoundPredicate.getBooleanOperator())) { throw new KiePMMLException(String.format("getConstraintEntriesFromXOrCompoundPredicate invoked with %s CompoundPredicate", compoundPredicate.getBooleanOperator())); } final List<Predicate> simplePredicates = compoundPredicate.getPredicates().stream().filter(predicate -> predicate instanceof SimplePredicate).collect(Collectors.toList()); if (simplePredicates.size() < 2) { throw new KiePMMLException("At least two elements expected for XOR operations"); } if (simplePredicates.size() > 2) { throw new KiePMMLException("More then two elements not managed, yet, for XOR operations"); } return getXORConstraintEntryFromSimplePredicates(simplePredicates, fieldTypeMap); }
KiePMMLASTFactoryUtils { public static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromXOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { if (!CompoundPredicate.BooleanOperator.XOR.equals(compoundPredicate.getBooleanOperator())) { throw new KiePMMLException(String.format("getConstraintEntriesFromXOrCompoundPredicate invoked with %s CompoundPredicate", compoundPredicate.getBooleanOperator())); } final List<Predicate> simplePredicates = compoundPredicate.getPredicates().stream().filter(predicate -> predicate instanceof SimplePredicate).collect(Collectors.toList()); if (simplePredicates.size() < 2) { throw new KiePMMLException("At least two elements expected for XOR operations"); } if (simplePredicates.size() > 2) { throw new KiePMMLException("More then two elements not managed, yet, for XOR operations"); } return getXORConstraintEntryFromSimplePredicates(simplePredicates, fieldTypeMap); } }
KiePMMLASTFactoryUtils { public static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromXOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { if (!CompoundPredicate.BooleanOperator.XOR.equals(compoundPredicate.getBooleanOperator())) { throw new KiePMMLException(String.format("getConstraintEntriesFromXOrCompoundPredicate invoked with %s CompoundPredicate", compoundPredicate.getBooleanOperator())); } final List<Predicate> simplePredicates = compoundPredicate.getPredicates().stream().filter(predicate -> predicate instanceof SimplePredicate).collect(Collectors.toList()); if (simplePredicates.size() < 2) { throw new KiePMMLException("At least two elements expected for XOR operations"); } if (simplePredicates.size() > 2) { throw new KiePMMLException("More then two elements not managed, yet, for XOR operations"); } return getXORConstraintEntryFromSimplePredicates(simplePredicates, fieldTypeMap); } private  KiePMMLASTFactoryUtils(); }
KiePMMLASTFactoryUtils { public static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromXOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { if (!CompoundPredicate.BooleanOperator.XOR.equals(compoundPredicate.getBooleanOperator())) { throw new KiePMMLException(String.format("getConstraintEntriesFromXOrCompoundPredicate invoked with %s CompoundPredicate", compoundPredicate.getBooleanOperator())); } final List<Predicate> simplePredicates = compoundPredicate.getPredicates().stream().filter(predicate -> predicate instanceof SimplePredicate).collect(Collectors.toList()); if (simplePredicates.size() < 2) { throw new KiePMMLException("At least two elements expected for XOR operations"); } if (simplePredicates.size() > 2) { throw new KiePMMLException("More then two elements not managed, yet, for XOR operations"); } return getXORConstraintEntryFromSimplePredicates(simplePredicates, fieldTypeMap); } 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); }
KiePMMLASTFactoryUtils { public static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromXOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { if (!CompoundPredicate.BooleanOperator.XOR.equals(compoundPredicate.getBooleanOperator())) { throw new KiePMMLException(String.format("getConstraintEntriesFromXOrCompoundPredicate invoked with %s CompoundPredicate", compoundPredicate.getBooleanOperator())); } final List<Predicate> simplePredicates = compoundPredicate.getPredicates().stream().filter(predicate -> predicate instanceof SimplePredicate).collect(Collectors.toList()); if (simplePredicates.size() < 2) { throw new KiePMMLException("At least two elements expected for XOR operations"); } if (simplePredicates.size() > 2) { throw new KiePMMLException("More then two elements not managed, yet, for XOR operations"); } return getXORConstraintEntryFromSimplePredicates(simplePredicates, fieldTypeMap); } 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);  }