class KiePMMLDroolsModelFactoryUtils {

    public static CompilationUnit getKiePMMLModelCompilationUnit(final DataDictionary dataDictionary,
                                                                 final Model model,
                                                                 final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                                 final String packageName,
                                                                 final String javaTemplate,
                                                                 final String modelClassName) {
        logger.trace("getKiePMMLModelCompilationUnit {} {} {}", dataDictionary, model, packageName);
        String className = getSanitizedClassName(model.getModelName());
        CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, javaTemplate, modelClassName);
        ClassOrInterfaceDeclaration modelTemplate = cloneCU.getClassByName(className)
                .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className));
        MINING_FUNCTION miningFunction = MINING_FUNCTION.byName(model.getMiningFunction().value());
        final ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, modelTemplate.getName())));
        String targetField = getTargetFieldName(dataDictionary, model).orElse(null);
        List<KiePMMLOutputField> outputFields = getOutputFields(model);
        setConstructor(model, constructorDeclaration, modelTemplate.getName(), targetField, miningFunction);
        addOutputFieldsPopulation(constructorDeclaration.getBody(), outputFields);
        addFieldTypeMapPopulation(constructorDeclaration.getBody(), fieldTypeMap);
        final MethodDeclaration getKModulePackageNameMethod = modelTemplate.getMethodsByName(GETKMODULEPACKAGENAME_METHOD).get(0);
        populateGetKModulePackageName(getKModulePackageNameMethod, packageName);
        return cloneCU;
    }

    private  KiePMMLDroolsModelFactoryUtils();

}