|
Yes, your workaround is correct, however, when you want to have a different Child's objects using common generic Parent functionality like:
class FirstChild extends Parent<FirstEntity> {}
class SecondChild extends Parent<SecondEntity> {}
then it is convenient to have an abstract parent() method that returns Parent<E> and a common submitEntity() method:
class EntityController<E> {
protected abstract Parent<E> parent();
protected void submitEntity(E entity) { parent().create(entity); }
}
the parent() method is then overriden in subclasses to return correct instance:
class FirstEntityController extends EntityController<FirstEntity> {
@Inject FirstChild firstChild;
protected Parent<FirstEntity> parent() { return firstChild; }
}
|