T
- destination dispatch type, methods will be looked up in the class of T
public class MethodNameInvoker<T> extends Object
Method
ahead of time).Constructor and Description |
---|
MethodNameInvoker(Dispatchable<T> target,
Class<T> targetClass)
Create a new method name invoker.
|
Modifier and Type | Method and Description |
---|---|
<K> K |
invoke(String methodName,
Object... params)
Invoke a method by its name.
|
public MethodNameInvoker(Dispatchable<T> target, Class<T> targetClass)
target
- destination dispatch type, invokes will be redirected to this dispatchertargetClass
- destination dispatch class, the invoked methods will be from this classpublic <K> K invoke(String methodName, Object... params)
If more than one method exists in targetClass
, the first method with the right
number of arguments will be used, and later calls will all use that method.
methodName
- The name of the method, which will be matched 1:1 to the destination methodparams
- Variadic parameter list.methodName
statically.IllegalArgumentException
- if methodName
does not exist on the target classThrowable
- will rethrow anything that the target method would normally throw