本文整理汇总了Java中com.badlogic.gdx.utils.reflect.Constructor.getParameterTypes方法的典型用法代码示例。如果您正苦于以下问题:Java Constructor.getParameterTypes方法的具体用法?Java Constructor.getParameterTypes怎么用?Java Constructor.getParameterTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.reflect.Constructor
的用法示例。
在下文中一共展示了Constructor.getParameterTypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processConstructor
import com.badlogic.gdx.utils.reflect.Constructor; //导入方法依赖的package包/类
/** @param constructor if all its parameter types are available in context, will be invoked and the instance will be
* added to context.
* @param context will be used to retrieve constructor parameters.
* @return an instance of the component or null if it cannot be constructed yet. */
private Object processConstructor(final Constructor constructor, final Context context) {
Object component;
if (constructor.getParameterTypes().length == 0) {
// Passing any empty object array avoid unnecessary array allocation.
component = invokeConstructor(constructor, Strings.EMPTY_ARRAY);
} else {
if (areContructorParametersAvailable(constructor, context)) {
final Object[] parameters = MethodInvocation.getParametersFromContext(constructor.getParameterTypes(),
context);
component = invokeConstructor(constructor, parameters);
} else {
delayedConstructions.add(constructor);
return null;
}
}
context.map(component);
return component;
}
示例2: processConstructor
import com.badlogic.gdx.utils.reflect.Constructor; //导入方法依赖的package包/类
/** @param constructor if all its parameter types are available in context, will be invoked and the instance will be
* added to context.
* @param context will be used to retrieve constructor parameters.
* @return an instance of the component or null if it cannot be constructed yet. */
private Object processConstructor(final Constructor constructor, final Context context) {
Object component;
if (constructor.getParameterTypes().length == 0) {
// Passing any empty object array avoid unnecessary array allocation.
component = invokeConstructor(constructor, Strings.EMPTY_ARRAY);
} else {
if (areContructorParametersAvailable(constructor, context)) {
final Object[] parameters = MethodInvocation.getParametersFromContext(constructor.getParameterTypes(),
context);
component = invokeConstructor(constructor, parameters);
} else {
return null;
}
}
context.map(component);
return component;
}
示例3: areContructorParametersAvailable
import com.badlogic.gdx.utils.reflect.Constructor; //导入方法依赖的package包/类
/** @param constructor its parameters will be validated.
* @param context contains components.
* @return true if all constructor parameters can be injected. */
private static boolean areContructorParametersAvailable(final Constructor constructor, final Context context) {
for (final Class<?> parameterType : constructor.getParameterTypes()) {
if (!context.isPresent(parameterType) && !context.isProviderPresentFor(parameterType)) {
return false;
}
}
return true;
}