@Test public void getPredicateFalse() { False falsePredicate = new False(); KiePMMLPredicate retrieved = KiePMMLPredicateFactory.getPredicate(falsePredicate, dataDictionary); assertTrue(retrieved instanceof KiePMMLFalsePredicate); }
public static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary) { logger.trace("getPredicate {}", predicate); if (predicate instanceof SimplePredicate) { final DataType dataType = dataDictionary.getDataFields().stream() .filter(dataField -> dataField.getName().getValue().equals(((SimplePredicate) predicate).getField().getValue())) .map(DataField::getDataType) .findFirst() .orElseThrow(() -> new KiePMMLException("Failed to find DataField for predicate " + ((SimplePredicate) predicate).getField().getValue())); return getKiePMMLSimplePredicate((SimplePredicate) predicate, dataType); } else if (predicate instanceof SimpleSetPredicate) { return getKiePMMLSimpleSetPredicate((SimpleSetPredicate) predicate); } else if (predicate instanceof CompoundPredicate) { return getKiePMMLCompoundPredicate((CompoundPredicate) predicate, dataDictionary); } else if (predicate instanceof True) { return getKiePMMLTruePredicate(); } else if (predicate instanceof False) { return getKiePMMLFalsePredicate(); } else { throw new KiePMMLException("Predicate of type " + predicate.getClass().getName() + " not managed, yet"); } }
KiePMMLPredicateFactory { public static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary) { logger.trace("getPredicate {}", predicate); if (predicate instanceof SimplePredicate) { final DataType dataType = dataDictionary.getDataFields().stream() .filter(dataField -> dataField.getName().getValue().equals(((SimplePredicate) predicate).getField().getValue())) .map(DataField::getDataType) .findFirst() .orElseThrow(() -> new KiePMMLException("Failed to find DataField for predicate " + ((SimplePredicate) predicate).getField().getValue())); return getKiePMMLSimplePredicate((SimplePredicate) predicate, dataType); } else if (predicate instanceof SimpleSetPredicate) { return getKiePMMLSimpleSetPredicate((SimpleSetPredicate) predicate); } else if (predicate instanceof CompoundPredicate) { return getKiePMMLCompoundPredicate((CompoundPredicate) predicate, dataDictionary); } else if (predicate instanceof True) { return getKiePMMLTruePredicate(); } else if (predicate instanceof False) { return getKiePMMLFalsePredicate(); } else { throw new KiePMMLException("Predicate of type " + predicate.getClass().getName() + " not managed, yet"); } } }
KiePMMLPredicateFactory { public static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary) { logger.trace("getPredicate {}", predicate); if (predicate instanceof SimplePredicate) { final DataType dataType = dataDictionary.getDataFields().stream() .filter(dataField -> dataField.getName().getValue().equals(((SimplePredicate) predicate).getField().getValue())) .map(DataField::getDataType) .findFirst() .orElseThrow(() -> new KiePMMLException("Failed to find DataField for predicate " + ((SimplePredicate) predicate).getField().getValue())); return getKiePMMLSimplePredicate((SimplePredicate) predicate, dataType); } else if (predicate instanceof SimpleSetPredicate) { return getKiePMMLSimpleSetPredicate((SimpleSetPredicate) predicate); } else if (predicate instanceof CompoundPredicate) { return getKiePMMLCompoundPredicate((CompoundPredicate) predicate, dataDictionary); } else if (predicate instanceof True) { return getKiePMMLTruePredicate(); } else if (predicate instanceof False) { return getKiePMMLFalsePredicate(); } else { throw new KiePMMLException("Predicate of type " + predicate.getClass().getName() + " not managed, yet"); } } private  KiePMMLPredicateFactory(); }
KiePMMLPredicateFactory { public static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary) { logger.trace("getPredicate {}", predicate); if (predicate instanceof SimplePredicate) { final DataType dataType = dataDictionary.getDataFields().stream() .filter(dataField -> dataField.getName().getValue().equals(((SimplePredicate) predicate).getField().getValue())) .map(DataField::getDataType) .findFirst() .orElseThrow(() -> new KiePMMLException("Failed to find DataField for predicate " + ((SimplePredicate) predicate).getField().getValue())); return getKiePMMLSimplePredicate((SimplePredicate) predicate, dataType); } else if (predicate instanceof SimpleSetPredicate) { return getKiePMMLSimpleSetPredicate((SimpleSetPredicate) predicate); } else if (predicate instanceof CompoundPredicate) { return getKiePMMLCompoundPredicate((CompoundPredicate) predicate, dataDictionary); } else if (predicate instanceof True) { return getKiePMMLTruePredicate(); } else if (predicate instanceof False) { return getKiePMMLFalsePredicate(); } else { throw new KiePMMLException("Predicate of type " + predicate.getClass().getName() + " not managed, yet"); } } private  KiePMMLPredicateFactory(); static List<KiePMMLPredicate> getPredicates(List<Predicate> predicates, DataDictionary dataDictionary); static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary); static KiePMMLSimplePredicate getKiePMMLSimplePredicate(SimplePredicate predicate, DataType dataType); static KiePMMLSimpleSetPredicate getKiePMMLSimpleSetPredicate(SimpleSetPredicate predicate); static KiePMMLCompoundPredicate getKiePMMLCompoundPredicate(CompoundPredicate predicate,
                                                                       DataDictionary dataDictionary); static KiePMMLTruePredicate getKiePMMLTruePredicate(); static KiePMMLFalsePredicate getKiePMMLFalsePredicate(); static Map<String, String> getPredicateSourcesMap(final KiePMMLPredicate kiePMMLPredicate,
                                                             final String packageName); }
KiePMMLPredicateFactory { public static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary) { logger.trace("getPredicate {}", predicate); if (predicate instanceof SimplePredicate) { final DataType dataType = dataDictionary.getDataFields().stream() .filter(dataField -> dataField.getName().getValue().equals(((SimplePredicate) predicate).getField().getValue())) .map(DataField::getDataType) .findFirst() .orElseThrow(() -> new KiePMMLException("Failed to find DataField for predicate " + ((SimplePredicate) predicate).getField().getValue())); return getKiePMMLSimplePredicate((SimplePredicate) predicate, dataType); } else if (predicate instanceof SimpleSetPredicate) { return getKiePMMLSimpleSetPredicate((SimpleSetPredicate) predicate); } else if (predicate instanceof CompoundPredicate) { return getKiePMMLCompoundPredicate((CompoundPredicate) predicate, dataDictionary); } else if (predicate instanceof True) { return getKiePMMLTruePredicate(); } else if (predicate instanceof False) { return getKiePMMLFalsePredicate(); } else { throw new KiePMMLException("Predicate of type " + predicate.getClass().getName() + " not managed, yet"); } } private  KiePMMLPredicateFactory(); static List<KiePMMLPredicate> getPredicates(List<Predicate> predicates, DataDictionary dataDictionary); static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary); static KiePMMLSimplePredicate getKiePMMLSimplePredicate(SimplePredicate predicate, DataType dataType); static KiePMMLSimpleSetPredicate getKiePMMLSimpleSetPredicate(SimpleSetPredicate predicate); static KiePMMLCompoundPredicate getKiePMMLCompoundPredicate(CompoundPredicate predicate,
                                                                       DataDictionary dataDictionary); static KiePMMLTruePredicate getKiePMMLTruePredicate(); static KiePMMLFalsePredicate getKiePMMLFalsePredicate(); static Map<String, String> getPredicateSourcesMap(final KiePMMLPredicate kiePMMLPredicate,
                                                             final String packageName);  }