Way to specify multiple interfaces in Java

You may try to use generics:

public < T extends HashClickHandlers & DoesFancyFeedback > void foo (
        T aThingIPassedIn
    )
{
    aThingIPassedIn.addClickHandler( );
    aThingIPassedIn.doFancyFeedback( );
}

No need for a third interface nor additional method.

Optional.ofNullable((HasClickHandlers & DoesFancyFeedback)clickyFeedbackThing).ifPresent(then -> {
    then.addClickHandler();
    then.doFancyFeedback();
});

I do not think that there is a better way to do what you want. I just wanted to suggest you to do the following. You can create method (let's call it foo) that accepts argument that requires 2 interfaces:

<T extends HasClickHandlers & DoesFancyFeedback> void foo(T arg);

Please pay attention on one ampersand between 2 your interfaces.


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.