自动获取泛型元类信息

@SuppressWarnings(“unchecked”) private Class getArgumentTypeClass(int argumentIndex) { try { Type actualTypeArgument = ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[argumentIndex]; return (Class) actualTypeArgument; } catch (RuntimeException ex) { throw new RuntimeException(“Cannot get Generic Class: argumentIndex = ” + argumentIndex, ex); } }