I need to implement a Facade design pattern with multiple inheritance of interfaces in Java or to be correct Facade with Bridge design pattern. I know this is possible because I saw it in as a part of one system, but I don't remember the implementation very well.
Here is my implementation so far:
public interface IOne {
public void methodOneIOne();
public void methodTwoIOne();
}
And its implementation:
public class One implements IOne {
@Override
public void methodOneIOne() {
System.out.println("methodOneIOne()");
}
@Override
public void methodTwoIOne() {
System.out.println("methodTwoIOne()");
} }
public interface ITwo {
public void methodOneITwo();
public void methodTwoITwo();
}
public class Two implements ITwo {
@Override
public void methodOneITwo() {
System.out.println("methodOneITwo()");
}
@Override
public void methodTwoITwo() {
System.out.println("methodTwoITwo()");
}}
And the facade:
public interface IFacade extends IOne, ITwo {}
So, from here I don't know where to go. If I create a class that implements IFacade, then it will be required to implement all of the methods, and this isn't what I want.
What are you actually trying to do with your facade class? If you are just trying to pass through most methods, possibly modifying a few then a dynamic proxy might be what you want.
Otherwise you would in fact have to implement all methods of IFacade
, as Java does not allow you to use multiple inheritance, so you could not extend both One
and Two
.