use of org.drools.mvelcompiler.util.BigDecimalArgumentCoercion in project drools by kiegroup.
the class ExpressionTyper method promoteBigDecimalParameters.
private void promoteBigDecimalParameters(MethodCallExpr methodCallExpr, Class[] argsType, Class<?>[] actualArgumentTypes) {
if (actualArgumentTypes.length == argsType.length && actualArgumentTypes.length == methodCallExpr.getArguments().size()) {
for (int i = 0; i < argsType.length; i++) {
Class<?> argumentType = argsType[i];
Class<?> actualArgumentType = actualArgumentTypes[i];
Expression argumentExpression = methodCallExpr.getArgument(i);
if (argumentType != actualArgumentType) {
Expression coercedExpression = new BigDecimalArgumentCoercion().coercedArgument(argumentType, actualArgumentType, argumentExpression);
methodCallExpr.setArgument(i, coercedExpression);
}
}
}
}
use of org.drools.mvelcompiler.util.BigDecimalArgumentCoercion in project drools by kiegroup.
the class MethodCallExprT method toJavaArgument.
private Expression toJavaArgument(List<TypedExpression> typedExpressions, int i) {
TypedExpression a = typedExpressions.get(i);
Optional<Class<?>> optionalActualType = Optional.empty();
if (actualMethodArgumentType.size() == typedExpressions.size()) {
optionalActualType = Optional.ofNullable(actualMethodArgumentType.get(i));
}
if (optionalActualType.isPresent() && a.getType().isPresent()) {
Type argumentTypeOrig = a.getType().get();
if (argumentTypeOrig instanceof Class) {
Class<?> argumentType = (Class<?>) argumentTypeOrig;
Class<?> actualType = optionalActualType.get();
if (argumentType != actualType) {
return new BigDecimalArgumentCoercion().coercedArgument(argumentType, actualType, (Expression) a.toJavaExpression());
}
}
}
return (Expression) a.toJavaExpression();
}
Aggregations