Search in sources :

Example 1 with BoxedParameters

use of org.drools.modelcompiler.builder.generator.BoxedParameters in project drools by kiegroup.

the class AbstractExpressionBuilder method addIndexedByDeclaration.

protected void addIndexedByDeclaration(TypedExpression left, TypedExpression right, boolean leftContainsThis, MethodCallExpr indexedByDSL, Collection<String> usedDeclarations) {
    LambdaExpr indexedByRightOperandExtractor = new LambdaExpr();
    BlockStmt lambdaBlock = new BlockStmt();
    NodeList<Parameter> parameters = new BoxedParameters(context).getBoxedParametersWithUnboxedAssignment(usedDeclarations, lambdaBlock);
    parameters.forEach(indexedByRightOperandExtractor::addParameter);
    TypedExpression expression = leftContainsThis ? right : left;
    indexedByRightOperandExtractor.setEnclosingParameters(true);
    lambdaBlock.addStatement(new ReturnStmt(expression.getExpression()));
    indexedByRightOperandExtractor.setBody(lambdaBlock);
    indexedByDSL.addArgument(indexedByRightOperandExtractor);
    indexedByDSL.addArgument(new ClassExpr(toJavaParserType(expression.getRawClass())));
}
Also used : LambdaExpr(com.github.javaparser.ast.expr.LambdaExpr) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) BoxedParameters(org.drools.modelcompiler.builder.generator.BoxedParameters) Parameter(com.github.javaparser.ast.body.Parameter) ClassExpr(com.github.javaparser.ast.expr.ClassExpr) TypedExpression(org.drools.modelcompiler.builder.generator.TypedExpression) ReturnStmt(com.github.javaparser.ast.stmt.ReturnStmt)

Aggregations

Parameter (com.github.javaparser.ast.body.Parameter)1 ClassExpr (com.github.javaparser.ast.expr.ClassExpr)1 LambdaExpr (com.github.javaparser.ast.expr.LambdaExpr)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 ReturnStmt (com.github.javaparser.ast.stmt.ReturnStmt)1 BoxedParameters (org.drools.modelcompiler.builder.generator.BoxedParameters)1 TypedExpression (org.drools.modelcompiler.builder.generator.TypedExpression)1