@Test public void addPredictorTerms() { final List<PredictorTerm> predictorTerms = IntStream.range(0, 3).mapToObj(index -> { String predictorName = "predictorName-" + index; double coefficient = 1.23 * index; String fieldRef = "fieldRef-" + index; return PMMLModelTestUtils.getPredictorTerm(predictorName, coefficient, Collections.singletonList(fieldRef)); }).collect(Collectors.toList()); ClassOrInterfaceDeclaration tableTemplate = new ClassOrInterfaceDeclaration(); Map<String, MethodDeclaration> retrieved = KiePMMLRegressionTableRegressionFactory.addPredictorTerms(predictorTerms, tableTemplate); assertEquals(predictorTerms.size(), retrieved.size()); IntStream.range(0, predictorTerms.size()).forEach(index -> { PredictorTerm predictorTerm = predictorTerms.get(index); assertTrue(retrieved.containsKey(predictorTerm.getName().getValue())); MethodDeclaration methodDeclaration = retrieved.get(predictorTerm.getName().getValue()); String expected = String.format("evaluatePredictorTerm%d", index + 1); assertEquals(expected, methodDeclaration.getNameAsString()); }); }
static Map<String, MethodDeclaration> addPredictorTerms(final List<PredictorTerm> predictorTerms, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); return predictorTerms.stream() .map(predictorTerm -> { int arity = predictorsArity.addAndGet(1); return new AbstractMap.SimpleEntry<>(predictorTerm.getName() != null ? predictorTerm.getName().getValue() : "predictorTerm" + arity, addPredictorTerm(predictorTerm, tableTemplate, arity)); }) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addPredictorTerms(final List<PredictorTerm> predictorTerms, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); return predictorTerms.stream() .map(predictorTerm -> { int arity = predictorsArity.addAndGet(1); return new AbstractMap.SimpleEntry<>(predictorTerm.getName() != null ? predictorTerm.getName().getValue() : "predictorTerm" + arity, addPredictorTerm(predictorTerm, tableTemplate, arity)); }) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addPredictorTerms(final List<PredictorTerm> predictorTerms, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); return predictorTerms.stream() .map(predictorTerm -> { int arity = predictorsArity.addAndGet(1); return new AbstractMap.SimpleEntry<>(predictorTerm.getName() != null ? predictorTerm.getName().getValue() : "predictorTerm" + arity, addPredictorTerm(predictorTerm, tableTemplate, arity)); }) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } private  KiePMMLRegressionTableRegressionFactory(); }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addPredictorTerms(final List<PredictorTerm> predictorTerms, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); return predictorTerms.stream() .map(predictorTerm -> { int arity = predictorsArity.addAndGet(1); return new AbstractMap.SimpleEntry<>(predictorTerm.getName() != null ? predictorTerm.getName().getValue() : "predictorTerm" + arity, addPredictorTerm(predictorTerm, tableTemplate, arity)); }) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } private  KiePMMLRegressionTableRegressionFactory(); static LinkedHashMap<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables,
                                                                                        final RegressionModel.NormalizationMethod normalizationMethod,
                                                                                        final List<KiePMMLOutputField> outputFields,
                                                                                        final String targetField,
                                                                                        final String packageName); static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable,
                                                               final RegressionModel.NormalizationMethod normalizationMethod,
                                                               final List<KiePMMLOutputField> outputFields,
                                                               final String targetField,
                                                               final String packageName); }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addPredictorTerms(final List<PredictorTerm> predictorTerms, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); return predictorTerms.stream() .map(predictorTerm -> { int arity = predictorsArity.addAndGet(1); return new AbstractMap.SimpleEntry<>(predictorTerm.getName() != null ? predictorTerm.getName().getValue() : "predictorTerm" + arity, addPredictorTerm(predictorTerm, tableTemplate, arity)); }) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } private  KiePMMLRegressionTableRegressionFactory(); static LinkedHashMap<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables,
                                                                                        final RegressionModel.NormalizationMethod normalizationMethod,
                                                                                        final List<KiePMMLOutputField> outputFields,
                                                                                        final String targetField,
                                                                                        final String packageName); static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable,
                                                               final RegressionModel.NormalizationMethod normalizationMethod,
                                                               final List<KiePMMLOutputField> outputFields,
                                                               final String targetField,
                                                               final String packageName); static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE_JAVA; static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE; }