当前位置: 首页>>代码示例>>Java>>正文


Java Constructor.getParameterTypes方法代码示例

本文整理汇总了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;
}
 
开发者ID:gdx-libs,项目名称:gdx-autumn,代码行数:23,代码来源:ContextInitializer.java

示例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;
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:22,代码来源:ContextInitializer.java

示例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;
}
 
开发者ID:gdx-libs,项目名称:gdx-autumn,代码行数:12,代码来源:ContextInitializer.java


注:本文中的com.badlogic.gdx.utils.reflect.Constructor.getParameterTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。