Source:
public static Map<String, String> getKiePMMLScorecardModelSourcesMap(final DataDictionary dataDictionary, final Scorecard model, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap, final String packageName) throws IOException { logger.trace("getKiePMMLScorecardModelSourcesMap {}", dataDictionary, model, packageName); String className = getSanitizedClassName(model.getModelName()); String targetField = getTargetFieldName(dataDictionary, model).orElse(null); List<KiePMMLOutputField> outputFields = getOutputFields(model); CompilationUnit templateCU = getFromFileName(KIE_PMML_SCORECARD_MODEL_TEMPLATE_JAVA); CompilationUnit cloneCU = templateCU.clone(); cloneCU.setPackageDeclaration(packageName); ClassOrInterfaceDeclaration modelTemplate = cloneCU.getClassByName(KIE_PMML_SCORECARD_MODEL_TEMPLATE) .orElseThrow(() -> new RuntimeException(MAIN_CLASS_NOT_FOUND)); modelTemplate.setName(className); setModelName(className, modelTemplate); MINING_FUNCTION miningFunction = MINING_FUNCTION.byName(model.getMiningFunction().value()); final ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format("Missing default constructor in ClassOrInterfaceDeclaration %s ", modelTemplate.getName()))); setConstructor(model, constructorDeclaration, modelTemplate.getName(), targetField, miningFunction); addOutputFieldsPopulation(constructorDeclaration.getBody(), outputFields); addFieldTypeMapPopulation(constructorDeclaration.getBody(), fieldTypeMap); Map<String, String> toReturn = new HashMap<>(); String fullClassName = packageName + "." + className; toReturn.put(fullClassName, cloneCU.toString()); return toReturn; }

Target:
public static Map<String, String> getKiePMMLScorecardModelSourcesMap(final DataDictionary dataDictionary, final Scorecard model, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap, final String packageName) throws IOException { logger.trace("getKiePMMLScorecardModelSourcesMap {}", dataDictionary, model, packageName); String className = getSanitizedClassName(model.getModelName()); String targetField = getTargetFieldName(dataDictionary, model).orElse(null); List<KiePMMLOutputField> outputFields = getOutputFields(model); CompilationUnit templateCU = getFromFileName(KIE_PMML_SCORECARD_MODEL_TEMPLATE_JAVA); CompilationUnit cloneCU = templateCU.clone(); cloneCU.setPackageDeclaration(packageName); ClassOrInterfaceDeclaration modelTemplate = cloneCU.getClassByName(KIE_PMML_SCORECARD_MODEL_TEMPLATE) .orElseThrow(() -> new RuntimeException(MAIN_CLASS_NOT_FOUND)); modelTemplate.setName(className); MINING_FUNCTION miningFunction = MINING_FUNCTION.byName(model.getMiningFunction().value()); final ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format("Missing default constructor in ClassOrInterfaceDeclaration %s ", modelTemplate.getName()))); setConstructor(model, constructorDeclaration, modelTemplate.getName(), targetField, miningFunction); addOutputFieldsPopulation(constructorDeclaration.getBody(), outputFields); addFieldTypeMapPopulation(constructorDeclaration.getBody(), fieldTypeMap); Map<String, String> toReturn = new HashMap<>(); String fullClassName = packageName + "." + className; toReturn.put(fullClassName, cloneCU.toString()); return toReturn; }