class PMMLRuleMapperFactory {

    public static String getPMMLRuleMapperSource(final String fullRuleName) {
        final String packageName = fullRuleName.contains(".") ? fullRuleName.substring(0,
                                                                                       fullRuleName.lastIndexOf('.')) : "";
        CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(KIE_PMML_RULE_MAPPER_CLASS_NAME, packageName, KIE_PMML_RULE_MAPPER_TEMPLATE_JAVA, KIE_PMML_RULE_MAPPER_CLASS_NAME);
        ClassOrInterfaceDeclaration typeDeclaration = (ClassOrInterfaceDeclaration) cloneCU.getTypes().get(0);
        FieldDeclaration ruleNameField =
                typeDeclaration.getFieldByName("model").orElseThrow(() -> new RuntimeException("The template " + KIE_PMML_RULE_MAPPER_TEMPLATE_JAVA + " has been modified."));
        ObjectCreationExpr objectCreationExpr = new ObjectCreationExpr();
        objectCreationExpr.setType(fullRuleName);
        ruleNameField.getVariables().get(0).setInitializer(objectCreationExpr);
        return cloneCU.toString();
    }

    private  PMMLRuleMapperFactory();

}