class PMMLRuleMappersFactory {

    public static String getPMMLRuleMappersSource(final String packageName, final List<String> generatedRuleMappers) {
        CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(KIE_PMML_RULE_MAPPERS_CLASS_NAME, packageName, KIE_PMML_RULE_MAPPERS_TEMPLATE_JAVA, KIE_PMML_RULE_MAPPERS_CLASS_NAME);
        ClassOrInterfaceDeclaration typeDeclaration = (ClassOrInterfaceDeclaration) cloneCU.getTypes().get(0);
        FieldDeclaration ruleNameField =
                typeDeclaration.getFieldByName("pmmlRuleMappers").orElseThrow(() -> new RuntimeException("The template " + KIE_PMML_RULE_MAPPERS_TEMPLATE_JAVA + " has been modified."));
        final List<Expression> nodeList = generatedRuleMappers.stream()
                .map(generatedRuleMapper -> {
                    ObjectCreationExpr objectCreationExpr = new ObjectCreationExpr();
                    objectCreationExpr.setType(generatedRuleMapper);
                    return objectCreationExpr;
                })
                .collect(Collectors.toList());
        NodeList<Expression> expressions = NodeList.nodeList(nodeList);
        MethodCallExpr methodCallExpr = new MethodCallExpr(new NameExpr("Arrays"), "asList", expressions);
        ruleNameField.getVariables().get(0).setInitializer(methodCallExpr);
        return cloneCU.toString();
    }

    private  PMMLRuleMappersFactory();

}