Search in sources :

Example 26 with NodeList

use of com.github.javaparser.ast.NodeList in project drools by kiegroup.

the class CommonCodegenUtilsTest method addMapPopulation.

@Test
public void addMapPopulation() {
    final Map<String, MethodDeclaration> toAdd = IntStream.range(0, 5).boxed().collect(Collectors.toMap(index -> "KEY_" + index, index -> getMethodDeclaration("METHOD_" + index)));
    BlockStmt body = new BlockStmt();
    String mapName = "MAP_NAME";
    CommonCodegenUtils.addMapPopulation(toAdd, body, mapName);
    NodeList<Statement> statements = body.getStatements();
    assertEquals(toAdd.size(), statements.size());
    for (Statement statement : statements) {
        assertTrue(statement instanceof ExpressionStmt);
        ExpressionStmt expressionStmt = (ExpressionStmt) statement;
        com.github.javaparser.ast.expr.Expression expression = expressionStmt.getExpression();
        assertTrue(expression instanceof MethodCallExpr);
        MethodCallExpr methodCallExpr = (MethodCallExpr) expression;
        final NodeList<com.github.javaparser.ast.expr.Expression> arguments = methodCallExpr.getArguments();
        assertEquals(2, arguments.size());
        assertTrue(arguments.get(0) instanceof StringLiteralExpr);
        assertTrue(arguments.get(1) instanceof MethodReferenceExpr);
        MethodReferenceExpr methodReferenceExpr = (MethodReferenceExpr) arguments.get(1);
        assertTrue(methodReferenceExpr.getScope() instanceof ThisExpr);
        final com.github.javaparser.ast.expr.Expression scope = methodCallExpr.getScope().orElse(null);
        assertNotNull(scope);
        assertTrue(scope instanceof NameExpr);
        assertEquals(mapName, ((NameExpr) scope).getNameAsString());
    }
    for (Map.Entry<String, MethodDeclaration> entry : toAdd.entrySet()) {
        int matchingDeclarations = (int) statements.stream().filter(statement -> {
            ExpressionStmt expressionStmt = (ExpressionStmt) statement;
            com.github.javaparser.ast.expr.Expression expression = expressionStmt.getExpression();
            MethodCallExpr methodCallExpr = (MethodCallExpr) expression;
            final NodeList<com.github.javaparser.ast.expr.Expression> arguments = methodCallExpr.getArguments();
            if (!entry.getKey().equals(((StringLiteralExpr) arguments.get(0)).getValue())) {
                return false;
            }
            MethodReferenceExpr methodReferenceExpr = (MethodReferenceExpr) arguments.get(1);
            return entry.getValue().getName().asString().equals(methodReferenceExpr.getIdentifier());
        }).count();
        assertEquals(1, matchingDeclarations);
    }
}
Also used : StaticJavaParser.parseClassOrInterfaceType(com.github.javaparser.StaticJavaParser.parseClassOrInterfaceType) Arrays(java.util.Arrays) ClassOrInterfaceType(com.github.javaparser.ast.type.ClassOrInterfaceType) ThisExpr(com.github.javaparser.ast.expr.ThisExpr) CommonCodegenUtils.literalExprFrom(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.literalExprFrom) NullLiteralExpr(com.github.javaparser.ast.expr.NullLiteralExpr) KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) ObjectCreationExpr(com.github.javaparser.ast.expr.ObjectCreationExpr) Map(java.util.Map) Expression(com.github.javaparser.ast.expr.Expression) Node(com.github.javaparser.ast.Node) NodeList(com.github.javaparser.ast.NodeList) SimpleName(com.github.javaparser.ast.expr.SimpleName) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) Collectors(java.util.stream.Collectors) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) ExplicitConstructorInvocationStmt(com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt) VariableDeclarationExpr(com.github.javaparser.ast.expr.VariableDeclarationExpr) Objects(java.util.Objects) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) LongLiteralExpr(com.github.javaparser.ast.expr.LongLiteralExpr) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) IntStream(java.util.stream.IntStream) ExpressionStmt(com.github.javaparser.ast.stmt.ExpressionStmt) ReturnStmt(com.github.javaparser.ast.stmt.ReturnStmt) Parameter(com.github.javaparser.ast.body.Parameter) Assert.assertThrows(org.junit.Assert.assertThrows) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator) Assert.assertSame(org.junit.Assert.assertSame) DoubleLiteralExpr(com.github.javaparser.ast.expr.DoubleLiteralExpr) OPTIONAL_FILTERED_KIEPMMLNAMEVALUE_NAME(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.OPTIONAL_FILTERED_KIEPMMLNAMEVALUE_NAME) StaticJavaParser.parseBlock(com.github.javaparser.StaticJavaParser.parseBlock) BooleanLiteralExpr(com.github.javaparser.ast.expr.BooleanLiteralExpr) Assert.assertNotNull(org.junit.Assert.assertNotNull) AssignExpr(com.github.javaparser.ast.expr.AssignExpr) BodyDeclaration(com.github.javaparser.ast.body.BodyDeclaration) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) CodegenTestUtils.commonValidateCompilation(org.kie.pmml.compiler.commons.testutils.CodegenTestUtils.commonValidateCompilation) NameExpr(com.github.javaparser.ast.expr.NameExpr) Statement(com.github.javaparser.ast.stmt.Statement) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) LAMBDA_PARAMETER_NAME(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.LAMBDA_PARAMETER_NAME) MethodReferenceExpr(com.github.javaparser.ast.expr.MethodReferenceExpr) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) IntegerLiteralExpr(com.github.javaparser.ast.expr.IntegerLiteralExpr) Assert.assertEquals(org.junit.Assert.assertEquals) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) NameExpr(com.github.javaparser.ast.expr.NameExpr) MethodReferenceExpr(com.github.javaparser.ast.expr.MethodReferenceExpr) ExpressionStmt(com.github.javaparser.ast.stmt.ExpressionStmt) Expression(com.github.javaparser.ast.expr.Expression) Expression(com.github.javaparser.ast.expr.Expression) Map(java.util.Map) HashMap(java.util.HashMap) ThisExpr(com.github.javaparser.ast.expr.ThisExpr) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) Test(org.junit.Test)

Example 27 with NodeList

use of com.github.javaparser.ast.NodeList in project drools by kiegroup.

the class CommonCodegenUtilsTest method addListPopulation.

@Test
public void addListPopulation() {
    final List<ObjectCreationExpr> toAdd = IntStream.range(0, 5).mapToObj(i -> {
        ObjectCreationExpr toReturn = new ObjectCreationExpr();
        toReturn.setType(String.class);
        Expression value = new StringLiteralExpr("String" + i);
        toReturn.setArguments(NodeList.nodeList(value));
        return toReturn;
    }).collect(Collectors.toList());
    BlockStmt body = new BlockStmt();
    String listName = "LIST_NAME";
    CommonCodegenUtils.addListPopulationByObjectCreationExpr(toAdd, body, listName);
    NodeList<Statement> statements = body.getStatements();
    assertEquals(toAdd.size(), statements.size());
    for (Statement statement : statements) {
        assertTrue(statement instanceof ExpressionStmt);
        ExpressionStmt expressionStmt = (ExpressionStmt) statement;
        assertTrue(expressionStmt.getExpression() instanceof MethodCallExpr);
        MethodCallExpr methodCallExpr = (MethodCallExpr) expressionStmt.getExpression();
        assertEquals(listName, methodCallExpr.getScope().get().asNameExpr().getNameAsString());
        NodeList<com.github.javaparser.ast.expr.Expression> arguments = methodCallExpr.getArguments();
        assertEquals(1, arguments.size());
        assertTrue(arguments.get(0) instanceof ObjectCreationExpr);
        ObjectCreationExpr objectCreationExpr = (ObjectCreationExpr) arguments.get(0);
        assertEquals(objectCreationExpr.getType().asString(), String.class.getSimpleName());
        arguments = objectCreationExpr.getArguments();
        assertEquals(1, arguments.size());
        assertTrue(arguments.get(0) instanceof StringLiteralExpr);
    }
    for (ObjectCreationExpr entry : toAdd) {
        int matchingDeclarations = (int) statements.stream().filter(statement -> {
            ExpressionStmt expressionStmt = (ExpressionStmt) statement;
            com.github.javaparser.ast.expr.Expression expression = expressionStmt.getExpression();
            MethodCallExpr methodCallExpr = (MethodCallExpr) expression;
            final NodeList<com.github.javaparser.ast.expr.Expression> arguments = methodCallExpr.getArguments();
            return entry.equals(arguments.get(0).asObjectCreationExpr());
        }).count();
        assertEquals(1, matchingDeclarations);
    }
}
Also used : ObjectCreationExpr(com.github.javaparser.ast.expr.ObjectCreationExpr) StaticJavaParser.parseClassOrInterfaceType(com.github.javaparser.StaticJavaParser.parseClassOrInterfaceType) Arrays(java.util.Arrays) ClassOrInterfaceType(com.github.javaparser.ast.type.ClassOrInterfaceType) ThisExpr(com.github.javaparser.ast.expr.ThisExpr) CommonCodegenUtils.literalExprFrom(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.literalExprFrom) NullLiteralExpr(com.github.javaparser.ast.expr.NullLiteralExpr) KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) ObjectCreationExpr(com.github.javaparser.ast.expr.ObjectCreationExpr) Map(java.util.Map) Expression(com.github.javaparser.ast.expr.Expression) Node(com.github.javaparser.ast.Node) NodeList(com.github.javaparser.ast.NodeList) SimpleName(com.github.javaparser.ast.expr.SimpleName) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) Collectors(java.util.stream.Collectors) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) ExplicitConstructorInvocationStmt(com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt) VariableDeclarationExpr(com.github.javaparser.ast.expr.VariableDeclarationExpr) Objects(java.util.Objects) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) LongLiteralExpr(com.github.javaparser.ast.expr.LongLiteralExpr) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) IntStream(java.util.stream.IntStream) ExpressionStmt(com.github.javaparser.ast.stmt.ExpressionStmt) ReturnStmt(com.github.javaparser.ast.stmt.ReturnStmt) Parameter(com.github.javaparser.ast.body.Parameter) Assert.assertThrows(org.junit.Assert.assertThrows) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator) Assert.assertSame(org.junit.Assert.assertSame) DoubleLiteralExpr(com.github.javaparser.ast.expr.DoubleLiteralExpr) OPTIONAL_FILTERED_KIEPMMLNAMEVALUE_NAME(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.OPTIONAL_FILTERED_KIEPMMLNAMEVALUE_NAME) StaticJavaParser.parseBlock(com.github.javaparser.StaticJavaParser.parseBlock) BooleanLiteralExpr(com.github.javaparser.ast.expr.BooleanLiteralExpr) Assert.assertNotNull(org.junit.Assert.assertNotNull) AssignExpr(com.github.javaparser.ast.expr.AssignExpr) BodyDeclaration(com.github.javaparser.ast.body.BodyDeclaration) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) CodegenTestUtils.commonValidateCompilation(org.kie.pmml.compiler.commons.testutils.CodegenTestUtils.commonValidateCompilation) NameExpr(com.github.javaparser.ast.expr.NameExpr) Statement(com.github.javaparser.ast.stmt.Statement) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) LAMBDA_PARAMETER_NAME(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.LAMBDA_PARAMETER_NAME) MethodReferenceExpr(com.github.javaparser.ast.expr.MethodReferenceExpr) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) IntegerLiteralExpr(com.github.javaparser.ast.expr.IntegerLiteralExpr) Assert.assertEquals(org.junit.Assert.assertEquals) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) ExpressionStmt(com.github.javaparser.ast.stmt.ExpressionStmt) Expression(com.github.javaparser.ast.expr.Expression) Expression(com.github.javaparser.ast.expr.Expression) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) Test(org.junit.Test)

Example 28 with NodeList

use of com.github.javaparser.ast.NodeList in project drools by kiegroup.

the class KiePMMLClusteringModelFactory method comparisonMeasureCreationExprFrom.

private static ObjectCreationExpr comparisonMeasureCreationExprFrom(ComparisonMeasure comparisonMeasure) {
    NodeList<Expression> arguments = new NodeList<>();
    arguments.add(literalExprFrom(comparisonMeasureKindFrom(comparisonMeasure.getKind())));
    arguments.add(literalExprFrom(aggregateFunctionFrom(comparisonMeasure.getMeasure())));
    arguments.add(literalExprFrom(compareFunctionFrom(comparisonMeasure.getCompareFunction())));
    return new ObjectCreationExpr(null, new ClassOrInterfaceType(null, KiePMMLComparisonMeasure.class.getCanonicalName()), arguments);
}
Also used : ObjectCreationExpr(com.github.javaparser.ast.expr.ObjectCreationExpr) Expression(com.github.javaparser.ast.expr.Expression) NodeList(com.github.javaparser.ast.NodeList) ClassOrInterfaceType(com.github.javaparser.ast.type.ClassOrInterfaceType)

Example 29 with NodeList

use of com.github.javaparser.ast.NodeList in project drools by kiegroup.

the class KiePMMLRegressionTableFactory method getCategoricalPredictorExpression.

/**
 * Create <b>CategoricalPredictor</b> <code>CastExpr</code> to the class
 * @param categoricalPredictorMapName
 * @return
 */
static CastExpr getCategoricalPredictorExpression(final String categoricalPredictorMapName) {
    final String lambdaExpressionMethodName = "evaluateCategoricalPredictor";
    final String parameterName = "input";
    final MethodCallExpr lambdaMethodCallExpr = new MethodCallExpr();
    lambdaMethodCallExpr.setName(lambdaExpressionMethodName);
    final NodeList<Expression> arguments = new NodeList<>();
    arguments.add(0, new NameExpr(parameterName));
    arguments.add(1, new NameExpr(categoricalPredictorMapName));
    lambdaMethodCallExpr.setArguments(arguments);
    final ExpressionStmt lambdaExpressionStmt = new ExpressionStmt(lambdaMethodCallExpr);
    final LambdaExpr lambdaExpr = new LambdaExpr();
    final Parameter lambdaParameter = new Parameter(new UnknownType(), parameterName);
    lambdaExpr.setParameters(NodeList.nodeList(lambdaParameter));
    lambdaExpr.setBody(lambdaExpressionStmt);
    lambdaMethodCallExpr.setScope(new NameExpr(KiePMMLRegressionTable.class.getSimpleName()));
    final ClassOrInterfaceType serializableFunctionType = getTypedClassOrInterfaceTypeByTypeNames(SerializableFunction.class.getCanonicalName(), Arrays.asList(String.class.getSimpleName(), Double.class.getSimpleName()));
    final CastExpr toReturn = new CastExpr();
    toReturn.setType(serializableFunctionType);
    toReturn.setExpression(lambdaExpr);
    return toReturn;
}
Also used : SerializableFunction(org.kie.pmml.api.iinterfaces.SerializableFunction) NodeList(com.github.javaparser.ast.NodeList) LambdaExpr(com.github.javaparser.ast.expr.LambdaExpr) NameExpr(com.github.javaparser.ast.expr.NameExpr) ClassOrInterfaceType(com.github.javaparser.ast.type.ClassOrInterfaceType) ExpressionStmt(com.github.javaparser.ast.stmt.ExpressionStmt) UnknownType(com.github.javaparser.ast.type.UnknownType) Expression(com.github.javaparser.ast.expr.Expression) CastExpr(com.github.javaparser.ast.expr.CastExpr) Parameter(com.github.javaparser.ast.body.Parameter) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr)

Example 30 with NodeList

use of com.github.javaparser.ast.NodeList in project drools by kiegroup.

the class KiePMMLRegressionTableFactory method getPredictorTermBody.

/**
 * Add a <b>PredictorTerm</b> <code>MethodDeclaration</code> to the class
 * @param predictorTerm
 * @return
 */
static BlockStmt getPredictorTermBody(final PredictorTerm predictorTerm) {
    try {
        templateEvaluate = getFromFileName(KIE_PMML_EVALUATE_METHOD_TEMPLATE_JAVA);
        cloneEvaluate = templateEvaluate.clone();
        ClassOrInterfaceDeclaration evaluateTemplateClass = cloneEvaluate.getClassByName(KIE_PMML_EVALUATE_METHOD_TEMPLATE).orElseThrow(() -> new RuntimeException(MAIN_CLASS_NOT_FOUND));
        MethodDeclaration methodTemplate = evaluateTemplateClass.getMethodsByName("evaluatePredictor").get(0);
        final BlockStmt body = methodTemplate.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodTemplate.getName())));
        VariableDeclarator variableDeclarator = getVariableDeclarator(body, "fieldRefs").orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_VARIABLE_IN_BODY, "fieldRefs", body)));
        final List<Expression> nodeList = predictorTerm.getFieldRefs().stream().map(fieldRef -> new StringLiteralExpr(fieldRef.getField().getValue())).collect(Collectors.toList());
        NodeList<Expression> expressions = NodeList.nodeList(nodeList);
        MethodCallExpr methodCallExpr = new MethodCallExpr(new NameExpr("Arrays"), "asList", expressions);
        variableDeclarator.setInitializer(methodCallExpr);
        variableDeclarator = getVariableDeclarator(body, COEFFICIENT).orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_VARIABLE_IN_BODY, COEFFICIENT, body)));
        variableDeclarator.setInitializer(String.valueOf(predictorTerm.getCoefficient().doubleValue()));
        return methodTemplate.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodTemplate.getName())));
    } catch (Exception e) {
        throw new KiePMMLInternalException(String.format("Failed to add PredictorTerm %s", predictorTerm), e);
    }
}
Also used : Arrays(java.util.Arrays) ClassOrInterfaceType(com.github.javaparser.ast.type.ClassOrInterfaceType) CommonCodegenUtils.createPopulatedHashMap(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.createPopulatedHashMap) KiePMMLModelUtils.getSanitizedVariableName(org.kie.pmml.commons.utils.KiePMMLModelUtils.getSanitizedVariableName) LoggerFactory(org.slf4j.LoggerFactory) MISSING_VARIABLE_IN_BODY(org.kie.pmml.commons.Constants.MISSING_VARIABLE_IN_BODY) MAIN_CLASS_NOT_FOUND(org.kie.pmml.compiler.commons.utils.JavaParserUtils.MAIN_CLASS_NOT_FOUND) NullLiteralExpr(com.github.javaparser.ast.expr.NullLiteralExpr) CategoricalPredictor(org.dmg.pmml.regression.CategoricalPredictor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ObjectCreationExpr(com.github.javaparser.ast.expr.ObjectCreationExpr) Map(java.util.Map) Expression(com.github.javaparser.ast.expr.Expression) CompilationUnit(com.github.javaparser.ast.CompilationUnit) NodeList(com.github.javaparser.ast.NodeList) UnknownType(com.github.javaparser.ast.type.UnknownType) CommonCodegenUtils.getTypedClassOrInterfaceTypeByTypeNames(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.getTypedClassOrInterfaceTypeByTypeNames) RegressionModel(org.dmg.pmml.regression.RegressionModel) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) NumericPredictor(org.dmg.pmml.regression.NumericPredictor) JavaParserUtils.getFullClassName(org.kie.pmml.compiler.commons.utils.JavaParserUtils.getFullClassName) MISSING_BODY_TEMPLATE(org.kie.pmml.commons.Constants.MISSING_BODY_TEMPLATE) UUID(java.util.UUID) RegressionTable(org.dmg.pmml.regression.RegressionTable) Collectors(java.util.stream.Collectors) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) VariableDeclarationExpr(com.github.javaparser.ast.expr.VariableDeclarationExpr) Objects(java.util.Objects) List(java.util.List) CommonCodegenUtils.getExpressionForObject(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.getExpressionForObject) SerializableFunction(org.kie.pmml.api.iinterfaces.SerializableFunction) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) KiePMMLRegressionTable(org.kie.pmml.models.regression.model.KiePMMLRegressionTable) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) TO_RETURN(org.kie.pmml.commons.Constants.TO_RETURN) VARIABLE_NAME_TEMPLATE(org.kie.pmml.commons.Constants.VARIABLE_NAME_TEMPLATE) LambdaExpr(com.github.javaparser.ast.expr.LambdaExpr) ExpressionStmt(com.github.javaparser.ast.stmt.ExpressionStmt) JavaParserUtils.getFromFileName(org.kie.pmml.compiler.commons.utils.JavaParserUtils.getFromFileName) Parameter(com.github.javaparser.ast.body.Parameter) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HashMap(java.util.HashMap) CastExpr(com.github.javaparser.ast.expr.CastExpr) AtomicReference(java.util.concurrent.atomic.AtomicReference) PredictorTerm(org.dmg.pmml.regression.PredictorTerm) LinkedHashMap(java.util.LinkedHashMap) VariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator) KiePMMLInternalException(org.kie.pmml.api.exceptions.KiePMMLInternalException) CommonCodegenUtils.addMapPopulationExpressions(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.addMapPopulationExpressions) RegressionCompilationDTO(org.kie.pmml.models.regression.compiler.dto.RegressionCompilationDTO) AbstractKiePMMLTable(org.kie.pmml.models.regression.model.AbstractKiePMMLTable) JavaParserUtils(org.kie.pmml.compiler.commons.utils.JavaParserUtils) Logger(org.slf4j.Logger) CommonCodegenUtils.getChainedMethodCallExprFrom(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.getChainedMethodCallExprFrom) NameExpr(com.github.javaparser.ast.expr.NameExpr) MethodReferenceExpr(com.github.javaparser.ast.expr.MethodReferenceExpr) CommonCodegenUtils.getVariableDeclarator(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.getVariableDeclarator) KiePMMLTableSourceCategory(org.kie.pmml.models.regression.model.tuples.KiePMMLTableSourceCategory) AbstractMap(java.util.AbstractMap) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) MISSING_VARIABLE_INITIALIZER_TEMPLATE(org.kie.pmml.commons.Constants.MISSING_VARIABLE_INITIALIZER_TEMPLATE) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) NameExpr(com.github.javaparser.ast.expr.NameExpr) KiePMMLInternalException(org.kie.pmml.api.exceptions.KiePMMLInternalException) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) VariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator) CommonCodegenUtils.getVariableDeclarator(org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.getVariableDeclarator) Expression(com.github.javaparser.ast.expr.Expression) KiePMMLInternalException(org.kie.pmml.api.exceptions.KiePMMLInternalException) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr)

Aggregations

NodeList (com.github.javaparser.ast.NodeList)83 Expression (com.github.javaparser.ast.expr.Expression)48 NameExpr (com.github.javaparser.ast.expr.NameExpr)40 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)37 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)36 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)29 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)25 ObjectCreationExpr (com.github.javaparser.ast.expr.ObjectCreationExpr)24 List (java.util.List)22 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)18 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)18 CompilationUnit (com.github.javaparser.ast.CompilationUnit)17 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)17 ArrayList (java.util.ArrayList)17 Collectors (java.util.stream.Collectors)17 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)16 ExpressionStmt (com.github.javaparser.ast.stmt.ExpressionStmt)16 Parameter (com.github.javaparser.ast.body.Parameter)15 Test (org.junit.Test)15 NullLiteralExpr (com.github.javaparser.ast.expr.NullLiteralExpr)14