Hi. I'm kind of lame with generics, but I wonder, for the following class:
static class SomeClass<T> {
private T value;
public SomeClass(T value) {
T.class?
this.value = value;
}
public T getValue() {
return value;
}
}
If called for example:
SomeClass<String> stringer = new SomeClass<String>("Hello");
Is it possible to get String.class
(or whatever T would be) in the constructor?
Ok, wait a sec, I'm going to explain what I'm trying to solve
The actual problem is that I'm using OrmLite and I have a lot of DAO objects, like this one:
public class PostDAO extends BaseJdbcDao<Post, String> {
public PostDAO(DatabaseType databaseType) {
super(databaseType, Post.class);
}
}
For Domain
it is:
public class DomainDAO extends BaseJdbcDao<Domain, String> {
public DomainDAO(DatabaseType databaseType) {
super(databaseType, Domain.class);
}
}
and so on. I wanted to parametrize these, so that I can only have one:
public class DAO<K, V> extends BaseJdbcDao<K, V> {
public DAO(DatabaseType databaseType) {
super(databaseType, (WHAT HERE?));
}
}
but I'm stuck on the what here
part)