org.test4j.tools.reflector
类 MethodAccessor<T>

java.lang.Object
  继承者 org.test4j.tools.reflector.MethodAccessor<T>

public class MethodAccessor<T>
extends Object


构造方法摘要
MethodAccessor(Class targetClaz, String methodName, Class... parametersType)
           
MethodAccessor(Method method)
           
MethodAccessor(Object target, String methodName, Class... parametersType)
           
 
方法摘要
 Method getMethod()
           
 T invoke(Object target, Object[] args)
           
static
<T> T
invokeMethod(Object target, Method method, Object... arguments)
          Invokes the given method with the given parameters on the given target object
static
<T> T
invokeMethod(Object target, String methodNmae, Object... paras)
           
static
<T> T
invokeMethodUnThrow(Object target, Method method, Object... arguments)
           
static
<T> T
invokeMethodUnThrow(Object target, String methodName, Object... paras)
          反射调用方法,不显式的抛出受检异常
原生的受检异常会被包装成运行时异常
 T invokeStatic(Object[] args)
           
 T invokeStaticUnThrow(Object[] args)
           
 T invokeUnThrow(Object target, Object[] args)
          调用方法,不显式抛出异常
原方法如果有显式异常,将被封装
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

MethodAccessor

public MethodAccessor(Class targetClaz,
                      String methodName,
                      Class... parametersType)

MethodAccessor

public MethodAccessor(Object target,
                      String methodName,
                      Class... parametersType)
参数:
targetObj -
targetClazz -
methodName -
parametersType -

MethodAccessor

public MethodAccessor(Method method)
方法详细信息

getMethod

public Method getMethod()

invoke

public T invoke(Object target,
                Object[] args)
         throws Exception
抛出:
Exception

invokeUnThrow

public T invokeUnThrow(Object target,
                       Object[] args)
调用方法,不显式抛出异常
原方法如果有显式异常,将被封装

参数:
target -
args -
返回:

invokeStatic

public T invokeStatic(Object[] args)
               throws Exception
抛出:
Exception

invokeStaticUnThrow

public T invokeStaticUnThrow(Object[] args)

invokeMethod

public static <T> T invokeMethod(Object target,
                                 Method method,
                                 Object... arguments)
                      throws Exception
Invokes the given method with the given parameters on the given target object

参数:
target - The object containing the method, not null
method - The method, not null
arguments - The method arguments
返回:
The result of the invocation, null if void
抛出:
Test4JException - if the method could not be invoked
Exception

invokeMethodUnThrow

public static <T> T invokeMethodUnThrow(Object target,
                                        Method method,
                                        Object... arguments)

invokeMethod

public static <T> T invokeMethod(Object target,
                                 String methodNmae,
                                 Object... paras)
                      throws Exception
抛出:
Exception

invokeMethodUnThrow

public static <T> T invokeMethodUnThrow(Object target,
                                        String methodName,
                                        Object... paras)
反射调用方法,不显式的抛出受检异常
原生的受检异常会被包装成运行时异常

类型参数:
T -
参数:
target -
methodName -
paras -
返回:


Copyright © 2013. All rights reserved.