@Test(expected = IllegalRetryException.class) public void testValidateRetryHandlerWithListUser() { RetryHandlerUtils.validateRetryHandler(ListUserRetryHandler.class); }
public static void validateRetryHandler(Class<?> clazz) { Type interfaceType = getRetryHandlerGenericInterface(clazz); Class<?> argsInputType = Object.class; if (interfaceType instanceof ParameterizedType) { Type type = ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; if (type instanceof Class) { argsInputType = (Class<?>) ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; } else { throw new IllegalRetryException("重试方法的参数类型不能是集合类等带泛型的"); } } if (Object.class.equals(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是Object或其他不能序列化和反序列化的类型"); } else if (Collection.class.isAssignableFrom(argsInputType) || Map.class.isAssignableFrom(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是集合类等带泛型的"); } }
RetryHandlerUtils { public static void validateRetryHandler(Class<?> clazz) { Type interfaceType = getRetryHandlerGenericInterface(clazz); Class<?> argsInputType = Object.class; if (interfaceType instanceof ParameterizedType) { Type type = ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; if (type instanceof Class) { argsInputType = (Class<?>) ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; } else { throw new IllegalRetryException("重试方法的参数类型不能是集合类等带泛型的"); } } if (Object.class.equals(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是Object或其他不能序列化和反序列化的类型"); } else if (Collection.class.isAssignableFrom(argsInputType) || Map.class.isAssignableFrom(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是集合类等带泛型的"); } } }
RetryHandlerUtils { public static void validateRetryHandler(Class<?> clazz) { Type interfaceType = getRetryHandlerGenericInterface(clazz); Class<?> argsInputType = Object.class; if (interfaceType instanceof ParameterizedType) { Type type = ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; if (type instanceof Class) { argsInputType = (Class<?>) ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; } else { throw new IllegalRetryException("重试方法的参数类型不能是集合类等带泛型的"); } } if (Object.class.equals(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是Object或其他不能序列化和反序列化的类型"); } else if (Collection.class.isAssignableFrom(argsInputType) || Map.class.isAssignableFrom(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是集合类等带泛型的"); } } private  RetryHandlerUtils(); }
RetryHandlerUtils { public static void validateRetryHandler(Class<?> clazz) { Type interfaceType = getRetryHandlerGenericInterface(clazz); Class<?> argsInputType = Object.class; if (interfaceType instanceof ParameterizedType) { Type type = ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; if (type instanceof Class) { argsInputType = (Class<?>) ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; } else { throw new IllegalRetryException("重试方法的参数类型不能是集合类等带泛型的"); } } if (Object.class.equals(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是Object或其他不能序列化和反序列化的类型"); } else if (Collection.class.isAssignableFrom(argsInputType) || Map.class.isAssignableFrom(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是集合类等带泛型的"); } } private  RetryHandlerUtils(); static boolean isRetryFunctionMethod(Method method); static void validateRetryHandler(Class<?> clazz); static void validateRetryFunction(Method method); static boolean isRetryHandlerMethod(Class<?> targetClass, Method method); static Type getRetryHandlerGenericInterface(Class<?> clazz); static String getMethodIdentity(Method method); }
RetryHandlerUtils { public static void validateRetryHandler(Class<?> clazz) { Type interfaceType = getRetryHandlerGenericInterface(clazz); Class<?> argsInputType = Object.class; if (interfaceType instanceof ParameterizedType) { Type type = ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; if (type instanceof Class) { argsInputType = (Class<?>) ((ParameterizedType) interfaceType).getActualTypeArguments()[0]; } else { throw new IllegalRetryException("重试方法的参数类型不能是集合类等带泛型的"); } } if (Object.class.equals(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是Object或其他不能序列化和反序列化的类型"); } else if (Collection.class.isAssignableFrom(argsInputType) || Map.class.isAssignableFrom(argsInputType)) { throw new IllegalRetryException("重试方法的参数类型[" + argsInputType + "]不能是集合类等带泛型的"); } } private  RetryHandlerUtils(); static boolean isRetryFunctionMethod(Method method); static void validateRetryHandler(Class<?> clazz); static void validateRetryFunction(Method method); static boolean isRetryHandlerMethod(Class<?> targetClass, Method method); static Type getRetryHandlerGenericInterface(Class<?> clazz); static String getMethodIdentity(Method method);  }