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