class KiePMMLRegressionTableClassificationFactory {

    static void populateOutputFieldsMapWithProbability(final BlockStmt body,
                                                               final List<KiePMMLOutputField> outputFields) {
        outputFields.stream()
                .filter(outputField -> PROBABILITY.equals(outputField.getResultFeature()))
                .forEach(outputField -> {
                    StringLiteralExpr key = new StringLiteralExpr(outputField.getName());
                    Expression value = null;
                    if (outputField.getValue() != null) {
                        NodeList<Expression> expressions =
                                NodeList.nodeList(new StringLiteralExpr(outputField.getValue().toString()));
                        value = new MethodCallExpr(new NameExpr("probabilityMap"), "get", expressions);
                    } else if (outputField.getTargetField().isPresent()) {
                        NodeList<Expression> expressions =
                                NodeList.nodeList(new StringLiteralExpr(outputField.getTargetField().get()));
                        value = new MethodCallExpr(new NameExpr("probabilityMap"), "get", expressions);
                    }
                    if (value != null) {
                        NodeList<Expression> expressions = NodeList.nodeList(key, value);
                        body.addStatement(new MethodCallExpr(new NameExpr("outputFieldsMap"), "put", expressions));
                    }
                });
    }

    private  KiePMMLRegressionTableClassificationFactory();

}