@Test public void transformMethodExpressionToMethodCallWithInlineCast() { typeResolver.addImport("org.drools.modelcompiler.domain.InternationalAddress"); final DrlxExpression expr = DrlxParseUtil.parseExpression("address#InternationalAddress.state"); final MethodCallExpr expected = StaticJavaParser.parseExpression("((InternationalAddress)getAddress()).getState()"); assertEquals(expected.toString(), new ToMethodCall(typeResolver).toMethodCallWithClassCheck(expr.getExpr(), null, Person.class).getExpression().toString()); }
public TypedExpression toMethodCallWithClassCheck(Expression expr, String bindingId, Class<?> clazz) { Deque<ParsedMethod> createExpressionCallLeftToRight = createExpressionCallLeftToRight(expr); previousClass = clazz; for (ParsedMethod e : createExpressionCallLeftToRight) { if (e.expression instanceof EnclosedExpr) { setCursorForEnclosedExpr(e); } else if (e.expression instanceof MethodCallExpr) { setCursorForMethodCall(e); } else { convertNameToMethod(bindingId, e); } } return new TypedExpression(previousScope, previousClass); }
ToMethodCall { public TypedExpression toMethodCallWithClassCheck(Expression expr, String bindingId, Class<?> clazz) { Deque<ParsedMethod> createExpressionCallLeftToRight = createExpressionCallLeftToRight(expr); previousClass = clazz; for (ParsedMethod e : createExpressionCallLeftToRight) { if (e.expression instanceof EnclosedExpr) { setCursorForEnclosedExpr(e); } else if (e.expression instanceof MethodCallExpr) { setCursorForMethodCall(e); } else { convertNameToMethod(bindingId, e); } } return new TypedExpression(previousScope, previousClass); } }
ToMethodCall { public TypedExpression toMethodCallWithClassCheck(Expression expr, String bindingId, Class<?> clazz) { Deque<ParsedMethod> createExpressionCallLeftToRight = createExpressionCallLeftToRight(expr); previousClass = clazz; for (ParsedMethod e : createExpressionCallLeftToRight) { if (e.expression instanceof EnclosedExpr) { setCursorForEnclosedExpr(e); } else if (e.expression instanceof MethodCallExpr) { setCursorForMethodCall(e); } else { convertNameToMethod(bindingId, e); } } return new TypedExpression(previousScope, previousClass); } ToMethodCall(RuleContext context);  ToMethodCall(TypeResolver typeResolver); }
ToMethodCall { public TypedExpression toMethodCallWithClassCheck(Expression expr, String bindingId, Class<?> clazz) { Deque<ParsedMethod> createExpressionCallLeftToRight = createExpressionCallLeftToRight(expr); previousClass = clazz; for (ParsedMethod e : createExpressionCallLeftToRight) { if (e.expression instanceof EnclosedExpr) { setCursorForEnclosedExpr(e); } else if (e.expression instanceof MethodCallExpr) { setCursorForMethodCall(e); } else { convertNameToMethod(bindingId, e); } } return new TypedExpression(previousScope, previousClass); } ToMethodCall(RuleContext context);  ToMethodCall(TypeResolver typeResolver); TypedExpression toMethodCallWithClassCheck(Expression expr, String bindingId, Class<?> clazz); Optional<Expression> getImplicitCastExpression(); }
ToMethodCall { public TypedExpression toMethodCallWithClassCheck(Expression expr, String bindingId, Class<?> clazz) { Deque<ParsedMethod> createExpressionCallLeftToRight = createExpressionCallLeftToRight(expr); previousClass = clazz; for (ParsedMethod e : createExpressionCallLeftToRight) { if (e.expression instanceof EnclosedExpr) { setCursorForEnclosedExpr(e); } else if (e.expression instanceof MethodCallExpr) { setCursorForMethodCall(e); } else { convertNameToMethod(bindingId, e); } } return new TypedExpression(previousScope, previousClass); } ToMethodCall(RuleContext context);  ToMethodCall(TypeResolver typeResolver); TypedExpression toMethodCallWithClassCheck(Expression expr, String bindingId, Class<?> clazz); Optional<Expression> getImplicitCastExpression();  }