KiePMMLRegressionTableRegressionFactory { public static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable, final RegressionModel.NormalizationMethod normalizationMethod, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName) { logger.trace("getRegressionTable {}", regressionTable); String className = "KiePMMLRegressionTableRegression" + classArity.addAndGet(1); CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE_JAVA, KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE); ClassOrInterfaceDeclaration tableTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final ConstructorDeclaration constructorDeclaration = tableTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, tableTemplate.getName()))); setConstructor(regressionTable, constructorDeclaration, tableTemplate.getName(), targetField); final Map<String, MethodDeclaration> numericPredictorsMap = addNumericPredictors(regressionTable.getNumericPredictors(), tableTemplate); final Map<String, MethodDeclaration> categoricalPredictorsMap = addCategoricalPredictors(regressionTable.getCategoricalPredictors(), tableTemplate); final Map<String, MethodDeclaration> predictorTermsMap = addPredictorTerms(regressionTable.getPredictorTerms(), tableTemplate); final BlockStmt body = constructorDeclaration.getBody(); addMapPopulation(numericPredictorsMap, body, "numericFunctionMap"); addMapPopulation(categoricalPredictorsMap, body, "categoricalFunctionMap"); addMapPopulation(predictorTermsMap, body, "predictorTermsFunctionMap"); populateGetTargetCategory(tableTemplate, regressionTable.getTargetCategory()); populateUpdateResult(tableTemplate, normalizationMethod); populateOutputFieldsMap(tableTemplate, outputFields); return new AbstractMap.SimpleEntry<>(getFullClassName(cloneCU), cloneCU.toString()); } 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; }
@Test public void getRegressionTableTest() { regressionTable = getRegressionTable(3.5, "professional"); List<RegressionTable> regressionTables = Collections.singletonList(regressionTable); Map<String, KiePMMLTableSourceCategory> retrieved = KiePMMLRegressionTableRegressionFactory.getRegressionTables(regressionTables, RegressionModel.NormalizationMethod.CAUCHIT, Collections.emptyList(), "targetField", "packageName"); assertNotNull(retrieved); retrieved.values().forEach(kiePMMLTableSourceCategory -> commonValidateKiePMMLRegressionTable(kiePMMLTableSourceCategory.getSource())); }