com.github.javaparser.ast.type.UnknownType Java Examples
The following examples show how to use
com.github.javaparser.ast.type.UnknownType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TriggerMetaData.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public static LambdaExpr buildLambdaExpr(Node node, ProcessMetaData metadata) { Map<String, Object> nodeMetaData = node.getMetaData(); TriggerMetaData triggerMetaData = new TriggerMetaData( (String) nodeMetaData.get(TRIGGER_REF), (String) nodeMetaData.get(TRIGGER_TYPE), (String) nodeMetaData.get(MESSAGE_TYPE), (String) nodeMetaData.get(MAPPING_VARIABLE), String.valueOf(node.getId())) .validate(); metadata.getTriggers().add(triggerMetaData); // and add trigger action BlockStmt actionBody = new BlockStmt(); CastExpr variable = new CastExpr( new ClassOrInterfaceType(null, triggerMetaData.getDataType()), new MethodCallExpr(new NameExpr(KCONTEXT_VAR), "getVariable") .addArgument(new StringLiteralExpr(triggerMetaData.getModelRef()))); MethodCallExpr producerMethodCall = new MethodCallExpr(new NameExpr("producer_" + node.getId()), "produce").addArgument(new MethodCallExpr(new NameExpr("kcontext"), "getProcessInstance")).addArgument(variable); actionBody.addStatement(producerMethodCall); return new LambdaExpr( new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) -> actionBody ); }
Example #2
Source File: RuleSetNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private MethodCallExpr handleDecision(RuleSetNode.RuleType.Decision ruleType) { StringLiteralExpr namespace = new StringLiteralExpr(ruleType.getNamespace()); StringLiteralExpr model = new StringLiteralExpr(ruleType.getModel()); Expression decision = ruleType.getDecision() == null ? new NullLiteralExpr() : new StringLiteralExpr(ruleType.getDecision()); MethodCallExpr decisionModels = new MethodCallExpr(new NameExpr("app"), "decisionModels"); MethodCallExpr decisionModel = new MethodCallExpr(decisionModels, "getDecisionModel") .addArgument(namespace) .addArgument(model); BlockStmt actionBody = new BlockStmt(); LambdaExpr lambda = new LambdaExpr(new Parameter(new UnknownType(), "()"), actionBody); actionBody.addStatement(new ReturnStmt(decisionModel)); return new MethodCallExpr(METHOD_DECISION) .addArgument(namespace) .addArgument(model) .addArgument(decision) .addArgument(lambda); }
Example #3
Source File: RuleSetNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private MethodCallExpr handleRuleFlowGroup(RuleSetNode.RuleType ruleType) { // build supplier for rule runtime BlockStmt actionBody = new BlockStmt(); LambdaExpr lambda = new LambdaExpr(new Parameter(new UnknownType(), "()"), actionBody); MethodCallExpr ruleRuntimeBuilder = new MethodCallExpr( new MethodCallExpr(new NameExpr("app"), "ruleUnits"), "ruleRuntimeBuilder"); MethodCallExpr ruleRuntimeSupplier = new MethodCallExpr( ruleRuntimeBuilder, "newKieSession", NodeList.nodeList(new StringLiteralExpr("defaultStatelessKieSession"), new NameExpr("app.config().rule()"))); actionBody.addStatement(new ReturnStmt(ruleRuntimeSupplier)); return new MethodCallExpr("ruleFlowGroup") .addArgument(new StringLiteralExpr(ruleType.getName())) .addArgument(lambda); }
Example #4
Source File: AbstractNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 5 votes |
protected static LambdaExpr createLambdaExpr(String consequence, VariableScope scope) { BlockStmt conditionBody = new BlockStmt(); List<Variable> variables = scope.getVariables(); variables.stream() .map(ActionNodeVisitor::makeAssignment) .forEach(conditionBody::addStatement); conditionBody.addStatement(new ReturnStmt(new EnclosedExpr(new NameExpr(consequence)))); return new LambdaExpr( new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) -> conditionBody ); }
Example #5
Source File: SplitNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Override public void visitNode(String factoryField, Split node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { body.addStatement(getAssignedFactoryMethod(factoryField, SplitFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId()))) .addStatement(getNameMethod(node, "Split")) .addStatement(getFactoryMethod(getNodeId(node), METHOD_TYPE, new IntegerLiteralExpr(node.getType()))); visitMetaData(node.getMetaData(), body, getNodeId(node)); if (node.getType() == Split.TYPE_OR || node.getType() == Split.TYPE_XOR) { for (Entry<ConnectionRef, Constraint> entry : node.getConstraints().entrySet()) { if (entry.getValue() != null) { BlockStmt actionBody = new BlockStmt(); LambdaExpr lambda = new LambdaExpr( new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) -> actionBody ); for (Variable v : variableScope.getVariables()) { actionBody.addStatement(makeAssignment(v)); } BlockStmt constraintBody = new BlockStmt(); constraintBody.addStatement(entry.getValue().getConstraint()); actionBody.addStatement(constraintBody); body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, new LongLiteralExpr(entry.getKey().getNodeId()), new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), new StringLiteralExpr(entry.getKey().getToType()), new StringLiteralExpr(entry.getValue().getDialect()), lambda, new IntegerLiteralExpr(entry.getValue().getPriority()))); } } } body.addStatement(getDoneMethod(getNodeId(node))); }
Example #6
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
@Override public void visit(final Parameter n, final Void arg) { printJavaComment(n.getComment(), arg); printAnnotations(n.getAnnotations(), false, arg); printModifiers(n.getModifiers()); n.getType().accept(this, arg); if (n.isVarArgs()) { printAnnotations(n.getVarArgsAnnotations(), false, arg); printer.print("..."); } if (!(n.getType() instanceof UnknownType)) { printer.print(" "); } n.getName().accept(this, arg); }
Example #7
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 4 votes |
@Override public void visit(final UnknownType n, final Void arg) { // Nothing to print }
Example #8
Source File: TraceVisitor.java From JCTools with Apache License 2.0 | 4 votes |
@Override public void visit(UnknownType n, Void arg) { out.println("UnknownType: " + (extended ? n : "")); super.visit(n, arg); }