类 MethodExecutionStrategy
java.lang.Object
com.obermuhlner.scriptengine.java.execution.MethodExecutionStrategy
- 所有已实现的接口:
ExecutionStrategy
The
ExecutionStrategy that executes a specific method.
This implementation has three static constructor methods to define the method that should be called:
byMethod(Method, Object...)to call the specified method and pass it the specified arguments.byArgumentTypes(Class, String, Class[], Object...)to call the public method with the specified argument types and pass it the specified arguments.byMatchingArguments(Class, String, Object...)to call a public method that matches the specified arguments.
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static MethodExecutionStrategybyArgumentTypes(Class<?> clazz, String methodName, Class<?>[] argumentTypes, Object... arguments) Creates aMethodExecutionStrategythat will call the public method with the specified argument types and passes the specified argument list.static MethodExecutionStrategybyMainMethod(Class<?> clazz, String... arguments) Creates aMethodExecutionStrategythat will call thepublic static void main(String[] args)with the specified arguments.static MethodExecutionStrategybyMatchingArguments(Class<?> clazz, String methodName, Object... arguments) Creates aMethodExecutionStrategythat will call a public method that matches the specified arguments.static MethodExecutionStrategyCreates aMethodExecutionStrategythat will call the specifiedMethod.Executes a method on an object instance, or a static method if the specified instance isnull.
-
字段详细资料
-
method
-
arguments
-
-
构造器详细资料
-
MethodExecutionStrategy
-
-
方法详细资料
-
execute
从接口复制的说明:ExecutionStrategyExecutes a method on an object instance, or a static method if the specified instance isnull.- 指定者:
execute在接口中ExecutionStrategy- 参数:
instance- the object instance to be executed ornullto execute a static method- 返回:
- the return value of the method, or
null - 抛出:
ScriptException- if no method to execute was found
-
byMethod
Creates aMethodExecutionStrategythat will call the specifiedMethod.- 参数:
method- theMethodto executearguments- the arguments to be passed to the method- 返回:
- the value returned by the method, or
null
-
byMainMethod
public static MethodExecutionStrategy byMainMethod(Class<?> clazz, String... arguments) throws ScriptException Creates aMethodExecutionStrategythat will call thepublic static void main(String[] args)with the specified arguments.- 参数:
clazz- theClassarguments- the arguments to pass to the main method- 返回:
- the created
MethodExecutionStrategy - 抛出:
ScriptException- if nopublic static void main(String[] args)method was found
-
byArgumentTypes
public static MethodExecutionStrategy byArgumentTypes(Class<?> clazz, String methodName, Class<?>[] argumentTypes, Object... arguments) throws ScriptException Creates aMethodExecutionStrategythat will call the public method with the specified argument types and passes the specified argument list.- 参数:
clazz- theClassmethodName- the method nameargumentTypes- the argument types defining the constructor to callarguments- the arguments to pass to the constructor (may containnull)- 返回:
- the created
MethodExecutionStrategy - 抛出:
ScriptException- if no matching public method was found
-
byMatchingArguments
public static MethodExecutionStrategy byMatchingArguments(Class<?> clazz, String methodName, Object... arguments) throws ScriptException Creates aMethodExecutionStrategythat will call a public method that matches the specified arguments. A method must match all specified arguments, exceptnullvalues which match any non-primitive type. The conversion from object types into corresponding primitive types (for exampleIntegerintoint) is handled automatically.- 参数:
clazz- theClassmethodName- the method namearguments- the arguments to be passed to the method- 返回:
- the created
MethodExecutionStrategy - 抛出:
ScriptException- if no matching public method was found
-