Dropwizard deserializing generic list from JerseyClient

老子叫甜甜 提交于 2019-12-01 08:06:00

Java's most popular excuse for Generics: Type Erasure

If you can pass your class type as Class<T> clazz, then you can use this:

GenericType<List<T>> genericType = new GenericType<>(new ParameterizedType() {
  public Type[] getActualTypeArguments() {
    return new Type[]{clazz};
  }

  public Type getRawType() {
    return List.class;
  }

  public Type getOwnerType() {
    return null;
  }
});
response.readEntity(genericType);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!