KiePMMLRegressionTableClassificationFactory { static void populateIsBinaryMethod(final OpType opType, int size, final ClassOrInterfaceDeclaration tableTemplate) { try { final MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("isBinary").get(0); boolean toReturn = Objects.equals(OpType.CATEGORICAL, opType) && size == 2; BlockStmt blockStmt = new BlockStmt(); blockStmt.addStatement(new ReturnStmt(new BooleanLiteralExpr(toReturn))); methodDeclaration.setBody(blockStmt); } catch (Exception e) { throw new KiePMMLInternalException(e.getMessage()); } } private  KiePMMLRegressionTableClassificationFactory(); static Map<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static Map.Entry<String, String> getRegressionTable(final LinkedHashMap<String, KiePMMLTableSourceCategory> regressionTablesMap, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static final String KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE_JAVA; static final String KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE; }
@Test public void populateIsBinaryMethod() { KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.CATEGORICAL, 1, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.CATEGORICAL, 2, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, true); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.CATEGORICAL, 3, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.CONTINUOUS, 1, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.CONTINUOUS, 2, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.CONTINUOUS, 3, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.ORDINAL, 1, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.ORDINAL, 2, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); KiePMMLRegressionTableClassificationFactory.populateIsBinaryMethod(OpType.ORDINAL, 3, modelTemplate); commonEvaluateIsBinaryMethod(modelTemplate, false); }