码迷,mamicode.com
首页 > 其他好文 > 详细

获取泛型类型

时间:2014-09-29 14:40:31      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   sp   div   c   log   r   

 1 private Class<T> clz;
 2  @SuppressWarnings("unchecked")
 3  public Class<T> getClz() {
 4   if (clz == null) {
 5    // 获取泛型的Class对象
 6    clz = ((Class<T>) (((ParameterizedType) (this.getClass()
 7      .getGenericSuperclass())).getActualTypeArguments()[0]));
 8   }
 9   return clz;
10  }

获取泛型类型

标签:style   blog   color   ar   sp   div   c   log   r   

原文地址:http://www.cnblogs.com/yuxinglab/p/3999963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!