How would you build a differentiated constructor for classes that span a generic class?
For example, for the situation below, I would like to create a Generic constructor that could accomplish the entity = E.class; statement, but for now I could not. So that it could be invoked in the constructor of the ItemManager class.
How could we do this?
public class Generic<E> {
private Class<E> entity;
public void setEntity(Class<E> entity) {
this.entity = entity;
}
public Generic() {
entity = E.class;
}
}
class ItemManager extends Generic<Item> {
public ItemManager() {
super();
}
}