Package java.lang.reflect

Examples of java.lang.reflect.TypeVariable


    assertFalse("Should not be bridge method", BridgeMethodResolver.isBridgeMethodFor(bridge, other, typeParameterMap));
  }

  public void testCreateTypeVariableMap() throws Exception {
    Map<String, Class> typeVariableMap = GenericTypeResolver.getTypeVariableMap(MyBar.class);
    TypeVariable barT = findTypeVariable(InterBar.class, "T");
    assertEquals(String.class, typeVariableMap.get(barT));

    typeVariableMap = GenericTypeResolver.getTypeVariableMap(MyFoo.class);
    TypeVariable fooT = findTypeVariable(Foo.class, "T");
    assertEquals(String.class, typeVariableMap.get(fooT));

    typeVariableMap = GenericTypeResolver.getTypeVariableMap(ExtendsEnclosing.ExtendsEnclosed.ExtendsReallyDeepNow.class);
    TypeVariable r = findTypeVariable(Enclosing.Enclosed.ReallyDeepNow.class, "R");
    TypeVariable s = findTypeVariable(Enclosing.Enclosed.class, "S");
    TypeVariable t = findTypeVariable(Enclosing.class, "T");
    assertEquals(Long.class, typeVariableMap.get(r));
    assertEquals(Integer.class, typeVariableMap.get(s));
    assertEquals(String.class, typeVariableMap.get(t));
  }
View Full Code Here


    assertEquals(bridgedMethod, BridgeMethodResolver.findBridgedMethod(bridgeMethod));
  }

  public void testSPR2454() throws Exception {
    Map typeVariableMap = GenericTypeResolver.getTypeVariableMap(YourHomer.class);
    TypeVariable variable = findTypeVariable(MyHomer.class, "L");
    assertEquals(AbstractBounded.class, ((ParameterizedType) typeVariableMap.get(variable)).getRawType());
  }
View Full Code Here

        } 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

        } 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

            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

        }
        if (type instanceof TypeVariable) {
            if (parameterizedTypes == null) {
                processParameterizedTypes();
            }
            TypeVariable var = (TypeVariable)type;
            Map<String, Class<?>> mp = parameterizedTypes.get(var.getGenericDeclaration());
            if (mp != null) {
                Class<?> c = parameterizedTypes.get(var.getGenericDeclaration()).get(var.getName());
                if (c != null) {
                    rawClass = c;
                    type = c;
                    part.getMessageInfo().setProperty("parameterized", Boolean.TRUE);
                }
View Full Code Here

                ParameterizedType pt = (ParameterizedType)t;
                Type[] args = pt.getActualTypeArguments();
                for (int i = 0; i < args.length; i++) {
                    Type arg = args[i];
                    if (arg instanceof TypeVariable) {
                        TypeVariable var = (TypeVariable)arg;
                        Type[] bounds = var.getBounds();
                        boolean isResolved = false;
                        for (int j = 0; j < bounds.length; j++) {
                            Class<?> cls = InjectionUtils.getRawType(bounds[j]);
                            if (cls != null && cls.isAssignableFrom(expectedType)) {
                                isResolved = true;
View Full Code Here

            }

            int i = 0;
            for (Type type : typeArguments)
            {
                TypeVariable typeVariable = typeVariables[i];
                Type[] bounds = typeVariable.getBounds();

                Class<?> clazzBound = (Class<?>) bounds[0];

                if (!clazzBound.isAssignableFrom((Class<?>) type))
                {
View Full Code Here

    {
        Asserts.assertNotNull(type, "type parameter can not be null");
       
        if (type instanceof TypeVariable)
        {
            TypeVariable wc = (TypeVariable)type;
            Type[] upper = wc.getBounds();           
           
           
            if(upper.length > 1)
            {
                return false;
View Full Code Here

        } 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

TOP

Related Classes of java.lang.reflect.TypeVariable

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.