本文整理汇总了Java中com.badlogic.gdx.utils.reflect.Method.getReturnType方法的典型用法代码示例。如果您正苦于以下问题:Java Method.getReturnType方法的具体用法?Java Method.getReturnType怎么用?Java Method.getReturnType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.reflect.Method
的用法示例。
在下文中一共展示了Method.getReturnType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToProviders
import com.badlogic.gdx.utils.reflect.Method; //导入方法依赖的package包/类
/** @param component is the owner of the methods.
* @param methods will be converted to dependency providers and added to context.
* @param context will contain the providers. Used to resolve methods' dependencies. */
protected void convertToProviders(final Object component, final Method[] methods, final Context context) {
for (final Method method : methods) {
final Class<?> returnType = method.getReturnType();
if (Annotations.isNotVoid(returnType)) { // Not null, void or Void.
context.addProvider(new ReflectionDependencyProvider(context, method, component));
}
}
}
示例2: isValidFactoryMethod
import com.badlogic.gdx.utils.reflect.Method; //导入方法依赖的package包/类
/** @param method cannot be synthetic, return void, have a forbidden name or have any filtered modifiers.
* @return true if the method is valid and should be converted to a provider. */
protected boolean isValidFactoryMethod(final Method method) {
final int modifiers = Modifier.getModifiers(method);
return (modifiers & getMethodsIgnoreFilter()) == 0 && modifiers != getMethodsIgnoreSignature()
&& method.getReturnType() != void.class && method.getReturnType() != Void.class
&& !FORBIDDEN_METHOD_NAMES.contains(method.getName());
}
示例3: ReflectionProvider
import com.badlogic.gdx.utils.reflect.Method; //导入方法依赖的package包/类
/** @param context parent context.
* @param owner instance of the class with the method.
* @param method will be wrapped and converted into a provider. */
public ReflectionProvider(final Context context, final Object owner, final Method method) {
this.context = context;
this.owner = owner;
this.method = method;
type = method.getReturnType();
parameterTypes = method.getParameterTypes();
parameters = parameterTypes.length == 0 ? Providers.EMPTY_ARRAY : new Object[parameterTypes.length];
name = Providers.getName(method);
isDefault = owner instanceof Default;
methodMember = new MethodMember(method);
}
示例4: initializeBehavior
import com.badlogic.gdx.utils.reflect.Method; //导入方法依赖的package包/类
/**
* Default implementation relies in reflection to set the attributes
*/
protected void initializeBehavior(S event, Class eventClass,
T runtimeBehavior) {
Method[] methods = ClassReflection.getDeclaredMethods(eventClass);
for (Method get : methods) {
String getPrefix = get.getName().startsWith("get") ? "get" : "is";
if (get.getName().startsWith("get")
|| get.getName().startsWith("is")) {
// Search equivalent set method in runtimeBehavior
String setMethodName = "set"
+ get.getName().substring(getPrefix.length());
Class returningType = get.getReturnType();
try {
Method set = ClassReflection.getDeclaredMethod(
runtimeBehavior.getClass(), setMethodName,
returningType);
if (set != null) {
set.invoke(runtimeBehavior, get.invoke(event));
}
} catch (ReflectionException e) {
Gdx.app.error("BehaviorComponent",
"Error initializing behavior", e);
}
}
}
if (eventClass.getSuperclass() != null
&& eventClass.getSuperclass() != Object.class) {
initializeBehavior(event, eventClass.getSuperclass(),
runtimeBehavior);
}
}