@Test public void testReturn_LV2Map() throws Exception { Class<?> clazz = Level2Mapper.class; Method method = clazz.getMethod("selectMap"); Type result = TypeParameterResolver.resolveReturnType(method, clazz); assertTrue(result instanceof ParameterizedType); ParameterizedType paramType = (ParameterizedType) result; assertEquals(Map.class, paramType.getRawType()); assertEquals(2, paramType.getActualTypeArguments().length); assertEquals(String.class, paramType.getActualTypeArguments()[0]); assertEquals(Integer.class, paramType.getActualTypeArguments()[1]); }
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);  }