原文:https://blog.csdn.net/u014723529/article/details/70574026

/**
 * 获取实体类型名称
 * 子类可覆盖此方法,返回:泛型T的类名.class.getSimpleName()
 * @return
 */
protected String getModelName() {
    Type t = getClass().getGenericSuperclass();    
    ParameterizedType p = (ParameterizedType) t ;    
    Class<T> c = (Class<T>) p.getActualTypeArguments()[0]; 
    return c.getSimpleName();
}

 

相关文章:

  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
  • 2021-12-25
  • 2022-03-09
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案