I have a class like:
public abstract class BaseDao {
protected Class getClazz() {
return T.class;
}
/
If your class is abstract, you can try with this:
public class getClassOfT() {
final ParameterizedType type = (ParameterizedType) this.getClass()
.getGenericSuperclass();
Class clazz = (Class) type.getActualTypeArguments()[0];
return clazz;
}
This only work if the instance is a direct subclass, and the type of the class you want is the first one (see the [0]).
If you have a large hierarchy of dao's, you can try fidn the BaseDao recursively and get the parametrized type
See a example here (see the output in the bottom)
Cheers and sorry for my bad english