docs: public static Type getGenericClassType(Object instance, Class<?> clazz, int position) {
      Class<?> type = instance.getClass();
      while (type != Object.class) {
        if (type.getGenericSuperclass() instanceof ParameterizedType) {
          ParameterizedType genericSuperclass = (ParameterizedType) type.getGenericSuperclass();
          if (genericSuperclass.getRawType() == clazz) {
            return genericSuperclass.getActualTypeArguments()[position];
          } else {
            type = type.getSuperclass();
          }
        } else {
          type = type.getSuperclass();
        }
      }
      return null;
    }