@Test public void testParam_Subclass() throws Exception { Class<?> clazz = SubCalculator.class; Method method = clazz.getMethod("setId", Object.class); Type[] result = TypeParameterResolver.resolveParamTypes(method, clazz); assertEquals(String.class, result[0]); }
public static Type[] resolveParamTypes(Method method, Type srcType) { Type[] paramTypes = method.getGenericParameterTypes(); Class<?> declaringClass = method.getDeclaringClass(); Type[] result = new Type[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { result[i] = resolveType(paramTypes[i], srcType, declaringClass); } return result; }
TypeParameterResolver { public static Type[] resolveParamTypes(Method method, Type srcType) { Type[] paramTypes = method.getGenericParameterTypes(); Class<?> declaringClass = method.getDeclaringClass(); Type[] result = new Type[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { result[i] = resolveType(paramTypes[i], srcType, declaringClass); } return result; } }
TypeParameterResolver { public static Type[] resolveParamTypes(Method method, Type srcType) { Type[] paramTypes = method.getGenericParameterTypes(); Class<?> declaringClass = method.getDeclaringClass(); Type[] result = new Type[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { result[i] = resolveType(paramTypes[i], srcType, declaringClass); } return result; } private  TypeParameterResolver(); }
TypeParameterResolver { public static Type[] resolveParamTypes(Method method, Type srcType) { Type[] paramTypes = method.getGenericParameterTypes(); Class<?> declaringClass = method.getDeclaringClass(); Type[] result = new Type[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { result[i] = resolveType(paramTypes[i], srcType, declaringClass); } return result; } 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[] resolveParamTypes(Method method, Type srcType) { Type[] paramTypes = method.getGenericParameterTypes(); Class<?> declaringClass = method.getDeclaringClass(); Type[] result = new Type[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { result[i] = resolveType(paramTypes[i], srcType, declaringClass); } return result; } private  TypeParameterResolver(); static Type resolveFieldType(Field field, Type srcType); static Type resolveReturnType(Method method, Type srcType); static Type[] resolveParamTypes(Method method, Type srcType);  }