美文网首页
获取类的Type,通过Type获取类的Class

获取类的Type,通过Type获取类的Class

作者: 唐岭云 | 来源:发表于2018-03-13 10:21 被阅读15次

获取类的Type

new TypeToken<XinYanBaseResult<XinYanBankCardInfoResult>>(){}.getType()

XinYanBaseResult<T>表示通用类;
XinYanBankCardInfoResult 泛型的具体类

Json开始转换具体类

XinYanBaseResult<T> result = JSONObject.parseObject(responseText, type);

获取泛型类的指定注解@LogOfDescribe

String var = ((ParameterizedType) type).getActualTypeArguments()[0].toString();
LogOfDescribe annotation = ClassUtils.getClass(var.replace("class", "")).getAnnotation(LogOfDescribe.class);

相关文章

网友评论

      本文标题:获取类的Type,通过Type获取类的Class

      本文链接:https://www.haomeiwen.com/subject/mjgafftx.html