@Test public void testReturn_Lv2CustomClassList() throws Exception { Class<?> clazz = Level2Mapper.class; Method method = clazz.getMethod("selectCalculatorList"); Type result = TypeParameterResolver.resolveReturnType(method, clazz); assertTrue(result instanceof ParameterizedType); ParameterizedType paramTypeOuter = (ParameterizedType) result; assertEquals(List.class, paramTypeOuter.getRawType()); assertEquals(1, paramTypeOuter.getActualTypeArguments().length); ParameterizedType paramTypeInner = (ParameterizedType) paramTypeOuter.getActualTypeArguments()[0]; assertEquals(Calculator.class, paramTypeInner.getRawType()); assertEquals(Date.class, paramTypeInner.getActualTypeArguments()[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);  }