use of org.drools.mvel.parser.ast.expr.ListCreationLiteralExpressionElement in project drools by kiegroup.
the class ExpressionTyper method listCreationLiteral.
private Optional<TypedExpressionCursor> listCreationLiteral(ListCreationLiteralExpression listCreationLiteralExpression, java.lang.reflect.Type originalTypeCursor) {
ClassOrInterfaceType arrayListType = (ClassOrInterfaceType) parseType(ArrayList.class.getCanonicalName());
BlockStmt initializationStmt = new BlockStmt();
InitializerDeclaration body = new InitializerDeclaration(false, initializationStmt);
ObjectCreationExpr newArrayListExpr = new ObjectCreationExpr(null, arrayListType, nodeList(), nodeList(), nodeList(body));
for (Expression e : listCreationLiteralExpression.getExpressions()) {
ListCreationLiteralExpressionElement expr = (ListCreationLiteralExpressionElement) e;
Expression value = resolveCreationLiteralNameExpr(originalTypeCursor, expr.getValue());
initializationStmt.addStatement(new MethodCallExpr(null, "add", nodeList(value)));
}
return of(new TypedExpressionCursor(newArrayListExpr, ArrayList.class));
}
Aggregations