Is it possible to cast an object in Java to a combined generic type?
I have a method like:
public static void doSomet
As a workaround, you could define another interface FooBar that extends Foo and Bar and have your class implement that. It doesn't even have to be a top-level interface - you can declare it private if you don't want to clutter up or retrofit the rest of your code:
private interface FooBar extends Foo, Bar {}
public void problemFunction (Object o) {
if ( o instanceof Foo && o instanceof Bar) {
doSomething((FooBar) o);
}
}