Class MethodResolutionUtils

java.lang.Object
org.drools.mvelcompiler.util.MethodResolutionUtils

public final class MethodResolutionUtils extends Object
  • Method Details

    • coerceCorrectConstructorArguments

      public static List<TypedExpression> coerceCorrectConstructorArguments(Class<?> type, List<TypedExpression> arguments, List<Integer> emptyCollectionArgumentsIndexes)
      [] is ambiguous in mvel - it can represent an empty list or an empty map. It cannot be distinguished on a language level, so this is a workaround: - When there [] written in a rule, mvel parser parses it as an empty list. - The only possible way with constructors, when there is such parameter, is try to guess the correct parameter type when trying to read the constructor from a class. - This uses all indexes of empty lists or empty maps in the constructor parameters. - When not possible to resolve the constructor with a list or map parameter, it will try to resolve a constructor with the other collection parameter. - This happens for all empty list and map parameters resolved by the parser, until a proper constructor is found.
    • resolveMethodWithEmptyCollectionArguments

      public static com.github.javaparser.utils.Pair<Optional<Method>,Optional<TypedExpression>> resolveMethodWithEmptyCollectionArguments(com.github.javaparser.ast.expr.MethodCallExpr methodExpression, MvelCompilerContext mvelCompilerContext, Optional<TypedExpression> scope, List<TypedExpression> arguments, List<Integer> emptyCollectionArgumentsIndexes)
      [] is ambiguous in mvel - it can represent an empty list or an empty map. It cannot be distinguished on a language level, so this is a workaround: - When there [] written in a rule, mvel parser parses it as an empty list. - The only possible way with methods, when there is such parameter, is try to guess the correct parameter type when trying to read the method from a class. - This uses all indexes of empty lists or empty maps in the method parameters. - When not possible to resolve the method with a list or map parameter, it will try to resolve a method with the other collection parameter. - This happens for all empty list and map parameters resolved by the parser, until a proper method is found.
    • resolveMethod

      public static com.github.javaparser.utils.Pair<Optional<Method>,Optional<TypedExpression>> resolveMethod(com.github.javaparser.ast.expr.MethodCallExpr methodExpression, MvelCompilerContext mvelCompilerContext, Optional<TypedExpression> scope, List<TypedExpression> arguments)
    • getTypedArgumentsWithEmptyCollectionArgumentDetection

      public static com.github.javaparser.utils.Pair<List<TypedExpression>,List<Integer>> getTypedArgumentsWithEmptyCollectionArgumentDetection(com.github.javaparser.ast.NodeList<com.github.javaparser.ast.expr.Expression> arguments, DrlGenericVisitor<TypedExpression,VisitorContext> drlGenericVisitor, VisitorContext arg)