Package com.alibaba.citrus.generictype

Examples of com.alibaba.citrus.generictype.TypeInfo


        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

            TypeInfo[] resolvedArgs = new TypeInfo[vars.size()];
            boolean resolved = true;
            boolean changed = false;

            for (int i = 0; i < resolvedArgs.length; i++) {
                TypeInfo arg = actualArgs.get(i);
                TypeInfo resolvedArg = arg.resolve(context, includeBaseType);

                if (arg != resolvedArg) {
                    changed = true;
                }
View Full Code Here

    }

    public TypeInfo getPrimitiveWrapperType() {
        if (isPrimitive()) {
            String name = getRawType().getName();
            TypeInfo wrapperType = PRIMITIVE_WRAPPERS.get(name);

            return assertNotNull(wrapperType, "Unknown primitive type: %s", name);
        }

        return this;
View Full Code Here

                    if (type == null) {
                        break;
                    }

                    TypeInfo typeInfo = factory.getType(type);

                    supertypes.add(typeInfo);
                    rawClass = typeInfo.getRawType();
                }
            }

            // interfaces
            int interfaceCount;

            for (interfaceCount = 0; !interfaceQueue.isEmpty(); interfaceCount++) {
                type = interfaceQueue.pop();

                TypeInfo typeInfo = factory.getType(type);

                supertypes.add(typeInfo);
                rawClass = typeInfo.getRawType();
                interfaceQueue.push(rawClass.getGenericInterfaces());
            }

            // Object
            if (hasObject) {
View Full Code Here

    public FieldInfo resolve(GenericDeclarationInfo context) {
        return resolve(context, true);
    }

    public FieldInfo resolve(GenericDeclarationInfo context, boolean includeBaseType) {
        TypeInfo resolvedType = type.resolve(context, includeBaseType);

        if (type != resolvedType) {
            return new FieldImpl(field, declaringType, resolvedType);
        } else {
            return this;
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.