本文整理匯總了Java中com.badlogic.gdx.utils.reflect.ClassReflection.getDeclaredMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassReflection.getDeclaredMethod方法的具體用法?Java ClassReflection.getDeclaredMethod怎麽用?Java ClassReflection.getDeclaredMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.reflect.ClassReflection
的用法示例。
在下文中一共展示了ClassReflection.getDeclaredMethod方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invoke
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
public void invoke(JGameObject clickTarget) {
for (Component component : clickTarget.getAllComponents()) {
if (component.getClass().getName().equals(invokeComponent)) {
Object[] parameters = args.toArray(new Object[args.size()]);
Class[] parametersType = new Class[args.size()];
for (int x = 0; x < parameters.length; x++) {
parametersType[x] = parameters[x].getClass();
}
try {
Method method = ClassReflection.getDeclaredMethod(component.getClass(), invokeMethod,
parametersType);
method.invoke(component, parameters);
} catch (ReflectionException e) {
e.printStackTrace();
}
}
}
}
示例2: Handler
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
/**
* Use for methods in context of some object as an owner.
*/
public Handler(Object methodOwner, String methodName, Class<? extends MessageBase> eventType) throws ReflectionException {
this.methodOwner = methodOwner;
this.methodName = methodName;
this.method = ClassReflection.getDeclaredMethod(methodOwner.getClass(), methodName, eventType);
this.eventType = eventType;
method.setAccessible(true);
}
示例3: getDeclaredMethod
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
private static Method getDeclaredMethod(final Class<?> containerClass, final String methodName,
final Class<?> parameterClass) throws ReflectionException {
if (parameterClass == null) {
return ClassReflection.getDeclaredMethod(containerClass, methodName);
}
return ClassReflection.getDeclaredMethod(containerClass, methodName, parameterClass);
}