@Test public void populateGetTargetCategoryTargetCategoryNull() { KiePMMLRegressionTableRegressionFactory.populateGetTargetCategory(modelTemplate, null); final Expression expectedExpression = new NameExpr("null"); commonEvaluateGetTargetCategory(modelTemplate, expectedExpression); }
static void populateGetTargetCategory(final ClassOrInterfaceDeclaration tableTemplate, final Object targetCategory) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("getTargetCategory").get(0); final BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration.getName()))); ReturnStmt returnStmt = new ReturnStmt(); if (targetCategory == null) { returnStmt.setExpression(new NameExpr("null")); } else if (targetCategory instanceof String) { returnStmt.setExpression(new StringLiteralExpr((String) targetCategory)); } else { returnStmt.setExpression(new NameExpr(targetCategory.toString())); } body.addStatement(returnStmt); }
KiePMMLRegressionTableRegressionFactory { static void populateGetTargetCategory(final ClassOrInterfaceDeclaration tableTemplate, final Object targetCategory) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("getTargetCategory").get(0); final BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration.getName()))); ReturnStmt returnStmt = new ReturnStmt(); if (targetCategory == null) { returnStmt.setExpression(new NameExpr("null")); } else if (targetCategory instanceof String) { returnStmt.setExpression(new StringLiteralExpr((String) targetCategory)); } else { returnStmt.setExpression(new NameExpr(targetCategory.toString())); } body.addStatement(returnStmt); } }
KiePMMLRegressionTableRegressionFactory { static void populateGetTargetCategory(final ClassOrInterfaceDeclaration tableTemplate, final Object targetCategory) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("getTargetCategory").get(0); final BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration.getName()))); ReturnStmt returnStmt = new ReturnStmt(); if (targetCategory == null) { returnStmt.setExpression(new NameExpr("null")); } else if (targetCategory instanceof String) { returnStmt.setExpression(new StringLiteralExpr((String) targetCategory)); } else { returnStmt.setExpression(new NameExpr(targetCategory.toString())); } body.addStatement(returnStmt); } private  KiePMMLRegressionTableRegressionFactory(); }
KiePMMLRegressionTableRegressionFactory { static void populateGetTargetCategory(final ClassOrInterfaceDeclaration tableTemplate, final Object targetCategory) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("getTargetCategory").get(0); final BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration.getName()))); ReturnStmt returnStmt = new ReturnStmt(); if (targetCategory == null) { returnStmt.setExpression(new NameExpr("null")); } else if (targetCategory instanceof String) { returnStmt.setExpression(new StringLiteralExpr((String) targetCategory)); } else { returnStmt.setExpression(new NameExpr(targetCategory.toString())); } body.addStatement(returnStmt); } private  KiePMMLRegressionTableRegressionFactory(); static LinkedHashMap<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables,
                                                                                        final RegressionModel.NormalizationMethod normalizationMethod,
                                                                                        final List<KiePMMLOutputField> outputFields,
                                                                                        final String targetField,
                                                                                        final String packageName); static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable,
                                                               final RegressionModel.NormalizationMethod normalizationMethod,
                                                               final List<KiePMMLOutputField> outputFields,
                                                               final String targetField,
                                                               final String packageName); }
KiePMMLRegressionTableRegressionFactory { static void populateGetTargetCategory(final ClassOrInterfaceDeclaration tableTemplate, final Object targetCategory) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("getTargetCategory").get(0); final BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration.getName()))); ReturnStmt returnStmt = new ReturnStmt(); if (targetCategory == null) { returnStmt.setExpression(new NameExpr("null")); } else if (targetCategory instanceof String) { returnStmt.setExpression(new StringLiteralExpr((String) targetCategory)); } else { returnStmt.setExpression(new NameExpr(targetCategory.toString())); } body.addStatement(returnStmt); } private  KiePMMLRegressionTableRegressionFactory(); static LinkedHashMap<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables,
                                                                                        final RegressionModel.NormalizationMethod normalizationMethod,
                                                                                        final List<KiePMMLOutputField> outputFields,
                                                                                        final String targetField,
                                                                                        final String packageName); static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable,
                                                               final RegressionModel.NormalizationMethod normalizationMethod,
                                                               final List<KiePMMLOutputField> outputFields,
                                                               final String targetField,
                                                               final String packageName); static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE_JAVA; static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE; }