On Tuesday, November 6, 2012 10:13:59 AM UTC+1, Thomas Broyer wrote:
>
> Couldn't you simply override the methods and refine the return type? (Java
> has covariant return types)
>
> interface Employee {
> Employee getBoss();
> }
>
> interface EmployeeProxy extends Employee, EntityProxy {
> EmployeeProxy getBoss();
> }
>
> class EmployeeEntity implements Employee {
> @Override
> public EmployeeEntity getBoss() { … }
> }
>
>
It gets more difficult for setters though:
interface Employee {
...
void setBoss(Boss boss);
}
can't be implemented in Java by
class EmployeeEntity implements Employee {
@Override
public void setBoss(BossEntity boss) { … }
}
So you could use generics
interface Employee<B extends Boss> {
...
void setBoss(B boss);
}
class EmployeeEntity implements Employee<BossEntity> {
@Override
public void setBoss(BossEntity boss) { … }
}
However, once I tried this (with GWT 2.5.0), it led to an Exception (only
when I define setters) - sorry, I don't exactly remember which Exception it
was, and I'm a little bit short of time at the moment to pursue it further.
(Maybe related to
http://code.google.com/p/google-web-toolkit/issues/detail?id=5762 ?)
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/RbSPxfagQzUJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.