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


Java CachedClass.getTheClass方法代码示例

本文整理汇总了Java中org.codehaus.groovy.reflection.CachedClass.getTheClass方法的典型用法代码示例。如果您正苦于以下问题:Java CachedClass.getTheClass方法的具体用法?Java CachedClass.getTheClass怎么用?Java CachedClass.getTheClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.groovy.reflection.CachedClass的用法示例。


在下文中一共展示了CachedClass.getTheClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyUse

import org.codehaus.groovy.reflection.CachedClass; //导入方法依赖的package包/类
private void applyUse(CachedClass cachedClass) {
    CachedMethod[] methods = cachedClass.getMethods();
    for (CachedMethod cachedMethod : methods) {
        if (cachedMethod.isStatic() && cachedMethod.isPublic()) {
            CachedClass[] paramTypes = cachedMethod.getParameterTypes();
            if (paramTypes.length > 0) {
                CachedClass metaClass = paramTypes[0];
                CategoryMethod mmethod = new CategoryMethod(cachedMethod, metaClass.getTheClass());
                final String name = cachedMethod.getName();
                CategoryMethodList list = get(name);
                if (list == null || list.level != level) {
                    list = new CategoryMethodList(name, level, list);
                    put(name, list);
                }
                list.add(mmethod);
                Collections.sort(list);
                cachePropertyAccessor(mmethod);
            }
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:GroovyCategorySupport.java

示例2: chooseMostGeneralMethodWith1NullParam

import org.codehaus.groovy.reflection.CachedClass; //导入方法依赖的package包/类
/**
 * Warning: this method does not choose properly if multiple methods with
 * the same distance are encountered
 * @param methods the methods to choose from
 * @return the method with 1 parameter which takes the most general type of
 *         object (e.g. Object) ignoring primitive types
 * @deprecated
 */
@Deprecated
public static Object chooseMostGeneralMethodWith1NullParam(FastArray methods) {
    // let's look for methods with 1 argument which matches the type of the
    // arguments
    CachedClass closestClass = null;
    CachedClass closestVargsClass = null;
    Object answer = null;
    int closestDist = -1;
    final int len = methods.size();
    for (int i = 0; i != len; ++i) {
        final Object[] data = methods.getArray();
        Object method = data[i];
        final ParameterTypes pt = (ParameterTypes) method;
        CachedClass[] paramTypes = pt.getParameterTypes();
        int paramLength = paramTypes.length;
        if (paramLength == 0 || paramLength > 2) continue;

        CachedClass theType = paramTypes[0];
        if (theType.isPrimitive) continue;

        if (paramLength == 2) {
            if (!pt.isVargsMethod(ARRAY_WITH_NULL)) continue;
            if (closestClass == null) {
                closestVargsClass = paramTypes[1];
                closestClass = theType;
                answer = method;
            } else if (closestClass.getTheClass() == theType.getTheClass()) {
                if (closestVargsClass == null) continue;
                CachedClass newVargsClass = paramTypes[1];
                if (isAssignableFrom(newVargsClass.getTheClass(), closestVargsClass.getTheClass())) {
                    closestVargsClass = newVargsClass;
                    answer = method;
                }
            } else if (isAssignableFrom(theType.getTheClass(), closestClass.getTheClass())) {
                closestVargsClass = paramTypes[1];
                closestClass = theType;
                answer = method;
            }
        } else {
            if (closestClass == null || isAssignableFrom(theType.getTheClass(), closestClass.getTheClass())) {
                closestVargsClass = null;
                closestClass = theType;
                answer = method;
                closestDist = -1;
            } else {
                // closestClass and theType are not in a subtype relation, we need
                // to check the distance to Object
                if (closestDist == -1) closestDist = closestClass.getSuperClassDistance();
                int newDist = theType.getSuperClassDistance();
                if (newDist < closestDist) {
                    closestDist = newDist;
                    closestVargsClass = null;
                    closestClass = theType;
                    answer = method;
                }
            }
        }
    }
    return answer;
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:69,代码来源:MetaClassHelper.java

示例3: getParameterType

import org.codehaus.groovy.reflection.CachedClass; //导入方法依赖的package包/类
public Class getParameterType(int index) {
    CachedClass c = parameterTypes[index];
    if (c==null) return Object.class;
    return c.getTheClass();
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:DefaultCachedMethodKey.java


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