Class MethodExecutionStrategy

    • Method Detail

      • execute

        public java.lang.Object execute​(java.lang.Object instance)
                                 throws javax.script.ScriptException
        Description copied from interface: ExecutionStrategy
        Executes a method on an object instance, or a static method if the specified instance is null.
        Specified by:
        execute in interface ExecutionStrategy
        Parameters:
        instance - the object instance to be executed or null to execute a static method
        Returns:
        the return value of the method, or null
        Throws:
        javax.script.ScriptException - if no method to execute was found
      • byMethod

        public static MethodExecutionStrategy byMethod​(java.lang.reflect.Method method,
                                                       java.lang.Object... arguments)
        Creates a MethodExecutionStrategy that will call the specified Method.
        Parameters:
        method - the Method to execute
        arguments - the arguments to be passed to the method
        Returns:
        the value returned by the method, or null
      • byArgumentTypes

        public static MethodExecutionStrategy byArgumentTypes​(java.lang.Class<?> clazz,
                                                              java.lang.String methodName,
                                                              java.lang.Class<?>[] argumentTypes,
                                                              java.lang.Object... arguments)
                                                       throws javax.script.ScriptException
        Creates a MethodExecutionStrategy that will call the public method with the specified argument types and passes the specified argument list.
        Parameters:
        clazz - the Class
        methodName - the method name
        argumentTypes - the argument types defining the constructor to call
        arguments - the arguments to pass to the constructor (may contain null)
        Returns:
        the created DefaultConstructorStrategy
        Throws:
        javax.script.ScriptException - if no matching public method was found
      • byMatchingArguments

        public static MethodExecutionStrategy byMatchingArguments​(java.lang.Class<?> clazz,
                                                                  java.lang.String methodName,
                                                                  java.lang.Object... arguments)
                                                           throws javax.script.ScriptException
        Creates a MethodExecutionStrategy that will call a public method that matches the specified arguments. A method must match all specified arguments, except null values which match any non-primitive type. The conversion from object types into corresponding primitive types (for example Integer into int) is handled automatically.
        Parameters:
        clazz - the Class
        methodName - the method name
        arguments - the arguments to be passed to the method
        Returns:
        the value returned by the method, or null
        Throws:
        javax.script.ScriptException - if no matching public method was found