Package com.alibaba.citrus.generictype

Examples of com.alibaba.citrus.generictype.TypeInfo


        TypeInfo[] exceptionTypes = new TypeInfo[this.exceptionTypes.size()];

        changed |= resolveTypes(this.parameterTypes, parameterTypes, context, includeBaseType);
        changed |= resolveTypes(this.exceptionTypes, exceptionTypes, context, includeBaseType);

        TypeInfo returnType = this.returnType.resolve(context, includeBaseType);

        if (returnType != this.returnType) {
            changed = true;
        }
View Full Code Here


    private boolean resolveTypes(List<TypeInfo> types, TypeInfo[] resolvedTypes, GenericDeclarationInfo context,
                                 boolean includeBaseType) {
        boolean changed = false;

        for (int i = 0; i < resolvedTypes.length; i++) {
            TypeInfo type = types.get(i);
            TypeInfo resolvedType = type.resolve(context, includeBaseType);

            if (type != resolvedType) {
                changed = true;
            }
View Full Code Here

    /** 取得指定{@link Field}对应的{@link FieldInfo}对象。 */
    @Override
    public final FieldInfo getField(Field field) {
        ClassTypeInfo declaringType = getClassType(field.getDeclaringClass());
        TypeInfo type = getType(field.getGenericType());

        return new FieldImpl(field, declaringType, type);
    }
View Full Code Here

        assertTrue(componentType instanceof RawTypeInfo || componentType instanceof ParameterizedTypeInfo
                   || componentType instanceof TypeVariableInfo, "unsupported componentType: %s", componentType);
        assertTrue(dimension > 0, "dimension");

        ArrayTypeInfo arrayType;
        TypeInfo directComponentType = dimension == 1 ? componentType : getArrayType(componentType, dimension - 1);

        if (componentType instanceof RawTypeInfo) {
            Class<?> type = ClassUtil.getArrayClass(componentType.getRawType(), dimension);

            arrayType = (ArrayTypeInfo) getFromClassCache(type);
View Full Code Here

                if (directComponentClass == null) {
                    directComponentClass = componentClass;
                }
            }

            TypeInfo componentType = buildRawType(componentClass, buildingCache);
            TypeInfo directComponentType = componentClass.equals(directComponentClass) ? componentType : buildType(
                    directComponentClass, buildingCache);

            arrayType = new ArrayTypeImpl(componentType, directComponentType, dimension, type);
            saveToClassCache(type, arrayType);
        }
View Full Code Here

            if (directComponent == null) {
                directComponent = component;
            }
        }

        TypeInfo componentType = buildType(component, buildingCache);
        TypeInfo directComponentType = component.equals(directComponent) ? componentType : buildType(directComponent,
                                                                                                     buildingCache);

        return new ArrayTypeImpl(componentType, directComponentType, dimension, null);
    }
View Full Code Here

            TypeInfo[] args = buildTypes(type.getActualTypeArguments(), buildingCache);

            // 修正wildcard的upper bounds为对应var的upper bounds
            // 例如,var为<T extends Number>,而wildcard未指定upper bounds,那么修正wildcard的upper bounds为Number
            for (int i = 0; i < args.length; i++) {
                TypeInfo arg = args[i];

                if (arg instanceof WildcardTypeInfo && ((WildcardTypeInfo) arg).isUnknown()) {
                    TypeVariable<?> var = rawType.getRawType().getTypeParameters()[i];
                    TypeInfo[] upperBounds = buildTypes(var.getBounds(), buildingCache);
View Full Code Here

    }

    private void buildMethodOrConstructor(MethodImpl method, Type returnType, Type[] parameterTypes,
                                          Type[] exceptionTypes, Class<?> declaringClass, BuildingCache buildingCache) {
        TypeVariableInfo[] vars = buildTypeVariables(method.declaration, method, buildingCache);
        TypeInfo returnTypeInfo = returnType == null ? TypeInfo.PRIMITIVE_VOID : buildType(returnType, buildingCache);
        TypeInfo[] parameterTypeInfos = buildTypes(parameterTypes, buildingCache);
        TypeInfo[] exceptionTypeInfos = buildTypes(exceptionTypes, buildingCache);
        ClassTypeInfo declaringType = buildRawType(declaringClass, buildingCache);

        method.init(vars, returnTypeInfo, parameterTypeInfos, exceptionTypeInfos, declaringType);
View Full Code Here

    }

    /** 在context中查找类型变量对应的实际类型。 */
    static TypeInfo resolveTypeVariable(TypeVariableInfo var, GenericDeclarationInfo context, boolean includeBaseType) {
        GenericDeclarationInfo declaration = assertNotNull(var, "var").getGenericDeclaration();
        TypeInfo result = null;

        // 当前var的declaration可能是: Class,带类型参数的method,带类型参数的constructor。
        //
        // 情形1. delcaration是Class,context也是Class,则在context.
        // supertypes中查找和declaration匹配的type
        if (declaration instanceof ClassTypeInfo && context instanceof ClassTypeInfo) {
            TypeInfo declarationEquivalent = findSupertype((ClassTypeInfo) context,
                                                           ((ClassTypeInfo) declaration).getRawType());

            if (declarationEquivalent != null) {
                if (!includeBaseType && declarationEquivalent instanceof RawTypeInfo) {
                    result = var;
                } else {
                    TypeInfo declarationResolved = declarationEquivalent.resolve(context, includeBaseType);

                    assertTrue(declarationResolved instanceof GenericDeclarationInfo,
                               "Unexpected declarationResolved: %s", declarationResolved);

                    result = ((GenericDeclarationInfo) declarationResolved).getActualTypeArgument(var.getName());
View Full Code Here

    /** 取得指定{@link Field}对应的{@link FieldInfo}对象。 */
    @Override
    public final FieldInfo getField(Field field) {
        ClassTypeInfo declaringType = getClassType(field.getDeclaringClass());
        TypeInfo type = getType(field.getGenericType());

        return new FieldImpl(field, declaringType, type);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.generictype.TypeInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.