@Test public void testReturn_Lv2WildcardList() throws Exception { Class<?> clazz = Level2Mapper.class; Method method = clazz.getMethod("selectWildcardList"); Type result = TypeParameterResolver.resolveReturnType(method, clazz); assertTrue(result instanceof ParameterizedType); ParameterizedType type = (ParameterizedType) result; assertEquals(List.class, type.getRawType()); assertEquals(1, type.getActualTypeArguments().length); assertTrue(type.getActualTypeArguments()[0] instanceof WildcardType); WildcardType wildcard = (WildcardType) type.getActualTypeArguments()[0]; assertEquals(0, wildcard.getLowerBounds().length); assertEquals(1, wildcard.getUpperBounds().length); assertEquals(String.class, wildcard.getUpperBounds()[0]); }
public static Type resolveReturnType(Method method, Type srcType) { Type returnType = method.getGenericReturnType(); Class<?> declaringClass = method.getDeclaringClass(); return resolveType(returnType, srcType, declaringClass); }
TypeParameterResolver { public static Type resolveReturnType(Method method, Type srcType) { Type returnType = method.getGenericReturnType(); Class<?> declaringClass = method.getDeclaringClass(); return resolveType(returnType, srcType, declaringClass); } }
TypeParameterResolver { public static Type resolveReturnType(Method method, Type srcType) { Type returnType = method.getGenericReturnType(); Class<?> declaringClass = method.getDeclaringClass(); return resolveType(returnType, srcType, declaringClass); } private  TypeParameterResolver(); }
TypeParameterResolver { public static Type resolveReturnType(Method method, Type srcType) { Type returnType = method.getGenericReturnType(); Class<?> declaringClass = method.getDeclaringClass(); return resolveType(returnType, srcType, declaringClass); } private  TypeParameterResolver(); static Type resolveFieldType(Field field, Type srcType); static Type resolveReturnType(Method method, Type srcType); static Type[] resolveParamTypes(Method method, Type srcType); }
TypeParameterResolver { public static Type resolveReturnType(Method method, Type srcType) { Type returnType = method.getGenericReturnType(); Class<?> declaringClass = method.getDeclaringClass(); return resolveType(returnType, srcType, declaringClass); } private  TypeParameterResolver(); static Type resolveFieldType(Field field, Type srcType); static Type resolveReturnType(Method method, Type srcType); static Type[] resolveParamTypes(Method method, Type srcType);  }