class PredictionRuleMapperGenerator {

    public static String getPredictionRuleMapperSource(final String fullRuleName) {
        final String packageName = fullRuleName.contains(".") ? fullRuleName.substring(0,
                                                                                       fullRuleName.lastIndexOf('.')) : "";
        CompilationUnit clazz =
                StaticJavaParser.parse(PredictionRuleMapperGenerator.class.getResourceAsStream(TEMPLATE_JAVA)).clone();
        if (!packageName.isEmpty()) {
            clazz.setPackageDeclaration(packageName);
        }
        ClassOrInterfaceDeclaration typeDeclaration = (ClassOrInterfaceDeclaration) clazz.getTypes().get(0);
        FieldDeclaration ruleNameField =
                typeDeclaration.getFieldByName("model").orElseThrow(() -> new RuntimeException("The template " + TEMPLATE_JAVA + " has been modified."));
        ObjectCreationExpr objectCreationExpr = new ObjectCreationExpr();
        objectCreationExpr.setType(fullRuleName);
        ruleNameField.getVariables().get(0).setInitializer(objectCreationExpr);
        return clazz.toString();
    }

    private  PredictionRuleMapperGenerator();

}