use of com.github.javaparser.ast.type.ClassOrInterfaceType in project cas by apereo.
the class ConfigurationMetadataFieldVisitor method processNestedClassOrInterfaceTypeIfNeeded.
private void processNestedClassOrInterfaceTypeIfNeeded(final FieldDeclaration n, final ConfigurationMetadataProperty prop) {
if (n.getElementType() instanceof ClassOrInterfaceType) {
val type = (ClassOrInterfaceType) n.getElementType();
if (!shouldTypeBeExcluded(type)) {
val instance = ConfigurationMetadataClassSourceLocator.getInstance();
val clz = instance.locatePropertiesClassForType(type);
if (clz != null && !clz.isMemberClass()) {
val typePath = ConfigurationMetadataClassSourceLocator.buildTypeSourcePath(this.sourcePath, clz.getName());
val parser = new ConfigurationMetadataUnitParser(this.sourcePath);
parser.parseCompilationUnit(properties, groups, prop, typePath, clz.getName(), false);
}
}
}
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class ExpressionTyper method mapCreationLiteral.
private Optional<TypedExpressionCursor> mapCreationLiteral(MapCreationLiteralExpression mapCreationLiteralExpression, java.lang.reflect.Type originalTypeCursor) {
ClassOrInterfaceType hashMapType = (ClassOrInterfaceType) parseType(HashMap.class.getCanonicalName());
BlockStmt initializationStmt = new BlockStmt();
InitializerDeclaration body = new InitializerDeclaration(false, initializationStmt);
ObjectCreationExpr newHashMapExpr = new ObjectCreationExpr(null, hashMapType, nodeList(), nodeList(), nodeList(body));
for (Expression e : mapCreationLiteralExpression.getExpressions()) {
MapCreationLiteralExpressionKeyValuePair expr = (MapCreationLiteralExpressionKeyValuePair) e;
Expression key = resolveCreationLiteralNameExpr(originalTypeCursor, expr.getKey());
Expression value = resolveCreationLiteralNameExpr(originalTypeCursor, expr.getValue());
initializationStmt.addStatement(new MethodCallExpr(null, "put", nodeList(key, value)));
}
return of(new TypedExpressionCursor(newHashMapExpr, HashMap.class));
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class FlowDSLQueryGenerator method queryNameClassArg.
private void queryNameClassArg(ClassOrInterfaceDeclaration clazz) {
MethodDeclaration query1 = clazz.addMethod(QUERY, Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC);
query1.addParameter(STRINGLITERAL, "name");
BlockStmt stmts = new BlockStmt();
NodeList<Type> typeArguments = nodeList();
NodeList<TypeParameter> typeParameters = nodeList();
NodeList<Expression> arguments = nodeList();
ClassOrInterfaceType queryCallViewItemImpl = queryDefImpl();
ObjectCreationExpr objCreationExpr = new ObjectCreationExpr(null, queryCallViewItemImpl, arguments);
objCreationExpr.setDiamondOperator();
stmts.addStatement(new ReturnStmt(objCreationExpr));
objCreationExpr.addArgument(new NameExpr(VIEWBUILDER));
objCreationExpr.addArgument("name");
rangeArity().forEach(i -> {
String genericTypeName = stringWithIndex("T", i);
String type = stringWithIndex("type", i);
String name = stringWithIndexInside(i);
typeArguments.add(parseType(genericTypeName));
arguments.add(new NameExpr(type));
arguments.add(new NameExpr(name));
String classGenericType = genericType(genericTypeName);
Type genericType = parseType(classGenericType);
query1.addParameter(genericType, type);
query1.addParameter(stringType(), name);
typeParameters.add(new TypeParameter(genericTypeName));
});
query1.setTypeParameters(typeParameters);
query1.setBody(stmts);
ClassOrInterfaceType type = queryDef();
type.setTypeArguments(typeArguments);
query1.setType(type);
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class FlowDSLQueryGenerator method queryPkgNameClassArg.
private void queryPkgNameClassArg(ClassOrInterfaceDeclaration clazz) {
MethodDeclaration query1 = clazz.addMethod(QUERY, Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC);
query1.addParameter(STRINGLITERAL, "pkg");
query1.addParameter(STRINGLITERAL, "name");
BlockStmt stmts = new BlockStmt();
NodeList<Type> typeArguments = nodeList();
NodeList<TypeParameter> typeParameters = nodeList();
NodeList<Expression> arguments = nodeList();
ClassOrInterfaceType queryCallViewItemImpl = queryDefImpl();
ObjectCreationExpr objCreationExpr = new ObjectCreationExpr(null, queryCallViewItemImpl, arguments);
objCreationExpr.setDiamondOperator();
stmts.addStatement(new ReturnStmt(objCreationExpr));
objCreationExpr.addArgument(new NameExpr(VIEWBUILDER));
objCreationExpr.addArgument("pkg");
objCreationExpr.addArgument("name");
rangeArity().forEach(i -> {
String genericTypeName = stringWithIndex("T", i);
String type = stringWithIndex("type", i);
String name = stringWithIndexInside(i);
typeArguments.add(parseType(genericTypeName));
arguments.add(new NameExpr(type));
arguments.add(new NameExpr(name));
String classGenericType = genericType(genericTypeName);
Type genericType = parseType(classGenericType);
query1.addParameter(genericType, type);
query1.addParameter(stringType(), name);
typeParameters.add(new TypeParameter(genericTypeName));
});
query1.setTypeParameters(typeParameters);
query1.setBody(stmts);
ClassOrInterfaceType type = queryDef();
type.setTypeArguments(typeArguments);
query1.setType(type);
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class QueryDefImplGenerator method callMethod.
private void callMethod(ClassOrInterfaceDeclaration clazz) {
MethodDeclaration method = clazz.addMethod("call", Modifier.Keyword.PUBLIC);
addOverride(method);
method.addParameter("boolean", "open");
method.setType(toClassOrInterfaceType(QueryCallViewItem.class));
BlockStmt statements = new BlockStmt();
NodeList<Expression> arguments = nodeList();
ClassOrInterfaceType queryCallViewItemImpl = toClassOrInterfaceType(QueryCallViewItemImpl.class);
ObjectCreationExpr objCreationExpr = new ObjectCreationExpr(null, queryCallViewItemImpl, arguments);
statements.addStatement(new ReturnStmt(objCreationExpr));
objCreationExpr.addArgument("this");
objCreationExpr.addArgument("open");
rangeArity().forEach(i -> {
String varWithIndex = stringWithIndex("var", i);
String genericTypeName = genericTypeName(i);
method.addParameter(genericType("Argument", genericTypeName), varWithIndex);
objCreationExpr.addArgument(varWithIndex);
});
method.setBody(statements);
}
Aggregations