static void setStaticGetter(final RegressionTable regressionTable,
                                final RegressionCompilationDTO compilationDTO,
                                final MethodDeclaration staticGetterMethod,
                                final String variableName) {
        final BlockStmt regressionTableBody =
                staticGetterMethod.getBody().orElseThrow(() -> new KiePMMLException(String.format(MISSING_BODY_TEMPLATE, staticGetterMethod)));

        final BlockStmt newBody = new BlockStmt();
        // populate maps
        String numericFunctionMapName = String.format(VARIABLE_NAME_TEMPLATE, NUMERIC_FUNCTION_MAP, variableName);
        final Map<String, Expression> numericPredictorsMap =
                getNumericPredictorsExpressions(regressionTable.getNumericPredictors());
        createPopulatedHashMap(newBody, numericFunctionMapName, Arrays.asList(String.class.getSimpleName(),
                                                                              "SerializableFunction<Double, Double>"),
                               numericPredictorsMap);

        final Map<String, Expression> categoricalPredictorFunctionsMap =
                getCategoricalPredictorsExpressions(regressionTable.getCategoricalPredictors(), newBody, variableName);
        String categoricalFunctionMapName = String.format(VARIABLE_NAME_TEMPLATE, CATEGORICAL_FUNCTION_MAP,
                                                          variableName);
        createPopulatedHashMap(newBody, categoricalFunctionMapName, Arrays.asList(String.class.getSimpleName(),
                                                                                  "SerializableFunction<String, " +
                                                                                          "Double>")
                , categoricalPredictorFunctionsMap);
        String predictorTermsFunctionMapName = String.format(VARIABLE_NAME_TEMPLATE, PREDICTOR_TERM_FUNCTION_MAP,
                                                             variableName);
        final Map<String, Expression> predictorTermsMap =
                getPredictorTermFunctions(regressionTable.getPredictorTerms());
        createPopulatedHashMap(newBody, predictorTermsFunctionMapName, Arrays.asList(String.class.getSimpleName(),
                                                                                     "SerializableFunction<Map" +
                                                                                             "<String, " +
                                                                                             "Object>, Double>"),
                               predictorTermsMap);

        final VariableDeclarator variableDeclarator =
                getVariableDeclarator(regressionTableBody, TO_RETURN).orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_IN_BODY, TO_RETURN, regressionTableBody)));
        final MethodCallExpr initializer = variableDeclarator.getInitializer()
                .orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_INITIALIZER_TEMPLATE,
                                                                      TO_RETURN, regressionTableBody)))
                .asMethodCallExpr();
        final MethodCallExpr builder = getChainedMethodCallExprFrom("builder", initializer);
        builder.setArgument(0, new StringLiteralExpr(variableName));
        getChainedMethodCallExprFrom("withNumericFunctionMap", initializer).setArgument(0,
                                                                                        new NameExpr(numericFunctionMapName) {
                                                                                        });
        getChainedMethodCallExprFrom("withCategoricalFunctionMap", initializer).setArgument(0,
                                                                                            new NameExpr(categoricalFunctionMapName));
        getChainedMethodCallExprFrom("withPredictorTermsFunctionMap", initializer).setArgument(0,
                                                                                               new NameExpr(predictorTermsFunctionMapName));
        getChainedMethodCallExprFrom("withIntercept", initializer).setArgument(0,
                                                                               getExpressionForObject(regressionTable.getIntercept().doubleValue()));

        getChainedMethodCallExprFrom("withTargetField", initializer).setArgument(0,
                                                                                 getExpressionForObject(compilationDTO.getTargetFieldName()));
        getChainedMethodCallExprFrom("withTargetCategory", initializer).setArgument(0,
                                                                                    getExpressionForObject(regressionTable.getTargetCategory()));
        final Expression resultUpdaterExpression =
                getResultUpdaterExpression(compilationDTO.getDefaultNormalizationMethod());
        getChainedMethodCallExprFrom("withResultUpdater", initializer).setArgument(0, resultUpdaterExpression);
        regressionTableBody.getStatements().forEach(newBody::addStatement);
        staticGetterMethod.setBody(newBody);
    }
@Test
    void setStaticGetter() throws IOException {
        regressionTable = getRegressionTable(3.5, "professional");
        RegressionModel regressionModel = new RegressionModel();
        regressionModel.setNormalizationMethod(RegressionModel.NormalizationMethod.CAUCHIT);
        regressionModel.addRegressionTables(regressionTable);
        regressionModel.setModelName(getGeneratedClassName("RegressionModel"));
        String targetField = "targetField";
        DataField dataField = new DataField();
        dataField.setName(targetField);
        dataField.setOpType(OpType.CATEGORICAL);
        DataDictionary dataDictionary = new DataDictionary();
        dataDictionary.addDataFields(dataField);
        MiningField miningField = new MiningField();
        miningField.setUsageType(MiningField.UsageType.TARGET);
        miningField.setName(dataField.getName());
        MiningSchema miningSchema = new MiningSchema();
        miningSchema.addMiningFields(miningField);
        regressionModel.setMiningSchema(miningSchema);
        PMML pmml = new PMML();
        pmml.setDataDictionary(dataDictionary);
        pmml.addModels(regressionModel);
        String variableName = "variableName";
        final CommonCompilationDTO<RegressionModel> source =
                CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME,
                                                                       pmml,
                                                                       regressionModel,
                                                                       new PMMLCompilationContextMock(),
                                                                       "FILENAME");
        final RegressionCompilationDTO compilationDTO =
                RegressionCompilationDTO.fromCompilationDTORegressionTablesAndNormalizationMethod(source,
                                                                                                  new ArrayList<>(),
                                                                                                  regressionModel.getNormalizationMethod());

        final MethodDeclaration staticGetterMethod = STATIC_GETTER_METHOD.clone();
        KiePMMLRegressionTableFactory.setStaticGetter(regressionTable,
                compilationDTO,
                staticGetterMethod,
                variableName);
        String text = getFileContent(TEST_06_SOURCE);
        MethodDeclaration expected = JavaParserUtils.parseMethod(text);
        assertThat(staticGetterMethod.toString()).isEqualTo(expected.toString());
        assertThat(JavaParserUtils.equalsNode(expected, staticGetterMethod)).isTrue();
        List<Class<?>> imports = Arrays.asList(AtomicReference.class,
                Collections.class,
                Arrays.class,
                List.class,
                Map.class,
                KiePMMLRegressionTable.class,
                SerializableFunction.class);
        commonValidateCompilationWithImports(staticGetterMethod, imports);
    }