Examples of TypeVariable


Examples of java.lang.reflect.TypeVariable

        } else if (type instanceof WildcardType) {
            WildcardType wType = (WildcardType)type;
            Type[] types = wType.getUpperBounds();
            return getErasure(types[0]);
        } else if (type instanceof TypeVariable) {
            TypeVariable var = (TypeVariable)type;
            Type[] types = var.getBounds();
            return getErasure(types[0]);
        }
        return null;
    }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

            GenericArrayType gt = (GenericArrayType)cls;
            Type componentType = gt.getGenericComponentType();
            if (componentType instanceof Class) {
                ct = (Class)componentType;
            } else {
                TypeVariable tv = (TypeVariable)componentType;
                Type[] bounds = tv.getBounds();
                if (bounds != null && bounds.length == 1) {
                    if (bounds[0] instanceof Class) {
                        ct = (Class)bounds[0];
                    } else {
                        throw new IllegalArgumentException("Unable to determine type for: " + tv);
View Full Code Here

Examples of java.lang.reflect.TypeVariable

        if (type instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType)type;
            return (Class<?>)pt.getRawType();
        }
        if (type instanceof TypeVariable) {
            TypeVariable tv = (TypeVariable)type;
            Type[] bounds = tv.getBounds();
            return (0 < bounds.length) ? erase(bounds[0]) : Object.class;
        }
        if (type instanceof WildcardType) {
            WildcardType wt = (WildcardType)type;
            Type[] bounds = wt.getUpperBounds();
View Full Code Here

Examples of java.lang.reflect.TypeVariable

        } else if (type instanceof WildcardType) {
            WildcardType wType = (WildcardType)type;
            Type[] types = wType.getUpperBounds();
            return getErasure(types[0]);
        } else if (type instanceof TypeVariable) {
            TypeVariable var = (TypeVariable)type;
            Type[] types = var.getBounds();
            return getErasure(types[0]);
        }
        return null;
    }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

            return getClassCode((Class)type);
        } else if (type instanceof GenericArrayType) {
            GenericArrayType at = (GenericArrayType)type;
            return "[" + getClassCode(at.getGenericComponentType());
        } else if (type instanceof TypeVariable) {
            TypeVariable tv = (TypeVariable)type;
            Type[] bounds = tv.getBounds();
            if (bounds != null && bounds.length == 1) {
                return getClassCode(bounds[0]);
            } else {
                throw new IllegalArgumentException("Unable to determine type for: " + tv);
            }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

            return getClassCode((Class)type);
        } else if (type instanceof GenericArrayType) {
            GenericArrayType at = (GenericArrayType)type;
            return "[" + getClassCode(at.getGenericComponentType());
        } else if (type instanceof TypeVariable) {
            TypeVariable tv = (TypeVariable)type;
            Type[] bounds = tv.getBounds();
            if (bounds != null && bounds.length == 1) {
                return getClassCode(bounds[0]);
            } else {
                throw new IllegalArgumentException("Unable to determine type for: " + tv);
            }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

  Class[] computeFieldGenerics (Type fieldGenericType, Field field, Class[] fieldClass) {
    Class[] fieldGenerics = null;
    if (fieldGenericType != null) {
      if (fieldGenericType instanceof TypeVariable && serializer.getGenericsScope() != null) {
        TypeVariable typeVar = (TypeVariable)fieldGenericType;
        // Obtain information about a concrete type of a given variable from the environment
        Class concreteClass = serializer.getGenericsScope().getConcreteClass(typeVar.getName());
        if (concreteClass != null) {
          fieldClass[0] = concreteClass;
          fieldGenerics = new Class[] {fieldClass[0]};
          if (TRACE)
            trace("kryo", "Determined concrete class of '" + field.getName() + "' to be " + fieldClass[0].getName());
View Full Code Here

Examples of java.lang.reflect.TypeVariable

    // Build a generics scope for this field
    Generics scope = buildGenericsScope(fieldClass[0], cachedFieldGenerics);

    // Is it a field of a generic parameter type, i.e. "T field"?
    if (fieldClass[0] == Object.class && fieldGenericType instanceof TypeVariable && serializer.getGenericsScope() != null) {
      TypeVariable typeVar = (TypeVariable)fieldGenericType;
      // Obtain information about a concrete type of a given variable from the environment
      Class concreteClass = serializer.getGenericsScope().getConcreteClass(typeVar.getName());
      if (concreteClass != null) {
        scope = new Generics();
        scope.add(typeVar.getName(), concreteClass);
      }
    }

    if (TRACE) {
      trace("kryo", "Generics scope of field '" + field.getName() + "' of class " + fieldGenericType + " is " + scope);
View Full Code Here

Examples of java.lang.reflect.TypeVariable

    public void givenTypeVariableWhenResolveThenResolved()
    {
        for( Method method : Type1.class.getMethods() )
        {
            Type type = method.getGenericReturnType();
            TypeVariable typeVariable = (TypeVariable) type;
            Type resolvedType = Classes.resolveTypeVariable( typeVariable, method.getDeclaringClass(), Type1.class );
            System.out.println( type + "=" + resolvedType );
        }
    }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

            {
                ParameterizedType pt = (ParameterizedType) type;
                Type collectionType = pt.getActualTypeArguments()[ 0 ];
                if( collectionType instanceof TypeVariable )
                {
                    TypeVariable collectionTypeVariable = (TypeVariable) collectionType;
                    collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass, compositeType );
                }
                ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module );
                valueType = new CollectionType( Classes.RAW_CLASS.map(type) , collectedType );
            }
            else
            {
                valueType = new CollectionType( Classes.RAW_CLASS.map(type) , newValueType( Object.class, declaringClass, compositeType, layer, module ) );
            }
        }
        else if( MapType.isMap( type ) )
        {
            if( type instanceof ParameterizedType )
            {
                ParameterizedType pt = (ParameterizedType) type;
                Type keyType = pt.getActualTypeArguments()[ 0 ];
                if( keyType instanceof TypeVariable )
                {
                    TypeVariable keyTypeVariable = (TypeVariable) keyType;
                    keyType = Classes.resolveTypeVariable( keyTypeVariable, declaringClass, compositeType );
                }
                ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module );

                Type valType = pt.getActualTypeArguments()[ 1 ];
                if( valType instanceof TypeVariable )
                {
                    TypeVariable valueTypeVariable = (TypeVariable) valType;
                    valType = Classes.resolveTypeVariable( valueTypeVariable, declaringClass, compositeType );
                }
                ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module );

                valueType = new MapType( Classes.RAW_CLASS.map(type) , keyedType, valuedType );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.