You can use a trick if your class has the type parameters set, because in that case the type information is available at runtime. You can capture it and store it in a member field. Then you can use that field as the class inside your generic construction method.
public abstract class AbstractDIDOModel<T>
{
private Class<?> persistentClass = (Class<?>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
private T getInstance(final HashMap<String, String> data)
{
T retObj = null;
try
{
Constructor ct = persistentClass.getDeclaredConstructor(HashMap.class);
Object[] argList = new Object[1];
argList[0] = data;
retObj = (T) ct.newInstance(argList);
} catch (Exception e)
{
} // try
return retObj;
}
Finally, declare your concrete classes as such:
public class MyClass<T extends AbstractModel>
{
....
}