class PMMLCompilerService {

    static void addPMMLRuleMapper(final KiePMMLModel kiePMMLModel, final List<String> generatedRuleMappers,
                                  final String sourcePath) {
        if (!(kiePMMLModel instanceof HasSourcesMap)) {
            String errorMessage = String.format("Expecting HasSourcesMap instance, retrieved %s inside %s",
                                                kiePMMLModel.getClass().getName(),
                                                sourcePath);
            throw new KiePMMLException(errorMessage);
        }
        if (kiePMMLModel instanceof HasRule) {
            String pkgUUID = ((HasRule)kiePMMLModel).getPkgUUID();
            String rulesFileName = kiePMMLModel.getKModulePackageName() + "." + RULES_FILE_NAME + pkgUUID;
            String pmmlRuleMapper = kiePMMLModel.getKModulePackageName() + "." + KIE_PMML_RULE_MAPPER_CLASS_NAME;
            String ruleMapperSource = PMMLRuleMapperFactory.getPMMLRuleMapperSource(rulesFileName);
            ((HasRule) kiePMMLModel).addSourceMap(pmmlRuleMapper, ruleMapperSource);
            generatedRuleMappers.add(pmmlRuleMapper);
        }
        if (kiePMMLModel instanceof HasNestedModels) {
            for (KiePMMLModel nestedModel : ((HasNestedModels) kiePMMLModel).getNestedModels()) {
                addPMMLRuleMapper(nestedModel, generatedRuleMappers, sourcePath);
            }
        }
    }

    private  PMMLCompilerService();

}