Code example for Field

Methods: getGenericType

0
 
    public void testFieldGenericType() throws Exception { 
        Field bString = fClass.getDeclaredField("bString");
        assertParameterizedType(bString.getGenericType(), bClass, String.class);
        Field listA = fClass.getDeclaredField("listA");
        assertParameterizedType(listA.getGenericType(), List.class, aClass);
    } 
 
    public void testConstructorGenericType() throws Exception { 
        Constructor<?> constructor = fClass.getDeclaredConstructors()[0];
        Type[] parameters = constructor.getGenericParameterTypes();
        assertParameterizedType(parameters[0], bClass, String.class);
        assertParameterizedType(parameters[1], List.class, aClass);
    } 
 
    public void testMethodGenericReturnType() throws Exception { 
        Method method = fClass.getDeclaredMethod("method", bClass, List.class);
        assertParameterizedType(method.getGenericReturnType(), bClass, String.class);
    } 
 
    public void testMethodGenericParameterTypes() throws Exception {