I have two interfaces, HasClickHandlers
and DoesFancyFeedback
. Then I have some UI objects that implement both interfaces - for example, a B
No, there is no such a thing in Java.
You would have to use the option you mention of creating a third interface. That way you'll be explicitly declaring your intention to use a new type.
Is not that verbose after all ( considering the alternative ), because you would just type:
public interface FancyWithHandler
extends HashClickHandlers , DoesFancyFeedback {}
You don't need to include the methods. And then just use it:
FancyWithHandler clickyFeedbackThing = aThingIPassedIn;
clickyFeedbackThing.addClickHandler();
clickyFeedbackThing.doFancyFeedback();
While the generic option looks interesting, probably at the end you'll end up creating a much more verbose thing.