I have two interfaces, HasClickHandlers and DoesFancyFeedback. Then I have some UI objects that implement both interfaces - for example, a Button that implements both has click handlers and also does fancy feedback.
In my code that's declaring Buttons, I don't want to actually say Button because maybe later I'll want it to be, I don't know. An Image that has click handlers and does fancy feedback. So instead of being specific and saying something like:
Button saveButton = aButtonIPassedIn;
saveButton.addClickHandler();
saveButton.doFancyFeedback();
I want to say,
{HasClickHandlers + DoesFancyFeedback} clickyFeedbackThing = aThingIPassedIn;
clickyFeedbackThing.addClickHandler();
clickyFeedbackThing.doFancyFeedback();
I want the compiler to require that aThingIPassedIn implement both HasClickHandlers and DoesFancyFeedback.
I could create an interface that extends those two interfaces, and use that. Is there any easier/less verbose way?