以下のキャストを回避できる方法はありますか?
//Is there a way this can be implemented so the cast is not necessary?
FooService fooService = new FooService();
Foo f = (Foo)fooService.findById(id);
public class FooService extends DomainServiceImpl<Foo> {
}
public class DomainService<T extends Persistable>{
private Class<T> type;
public void findById(long id) {
domainDao.findById(id, type);
}
}
編集:まだキャストする必要があります
public T findById(long id) {
return (T) fooDao.findById(id, type);
}