use of org.drools.javaparser.ast.expr.StringLiteralExpr in project drools by kiegroup.
the class NamedConsequenceVisitor method whenThenDSL.
private MethodCallExpr whenThenDSL(ConditionalBranchDescr desc, PatternDescr patternRelated, Class<?> patternType, String callMethod, MethodCallExpr parentExpression) {
MethodCallExpr when = new MethodCallExpr(parentExpression, callMethod);
final String condition = desc.getCondition().toString();
if (!condition.equals("true")) {
// Default case
when.addArgument(new StringLiteralExpr(context.getConditionId(patternType, condition)));
when.addArgument(new NameExpr(toVar(patternRelated.getIdentifier())));
DrlxParseResult parseResult = new ConstraintParser(context, packageModel).drlxParse(patternType, patternRelated.getIdentifier(), condition);
parseResult.accept(parseSuccess -> when.addArgument(generateLambdaWithoutParameters(Collections.emptySortedSet(), parseSuccess.getExpr())));
}
MethodCallExpr then = new MethodCallExpr(when, THEN_CALL);
MethodCallExpr rhs = onDSL(desc.getConsequence());
then.addArgument(rhs);
return then;
}
Aggregations