我有一个P包裹
public interface Ipublic class S1 extends Foo implements Ipublic class S2 extends Bar implements I.
现在我想禁止I外部的实现P,但I应该公开,因为我将它用于public method(I parameter).
如何才能做到这一点?
是否有一些“包装最终模式”?
你有过这样的情况吗?
细节:
我知道使用仅包私有构造函数而不是 interface 的抽象类的可能性I,但是S1并S2扩展不同的类,所以我需要多重继承(因为模拟多重继承(参见例如 Effective Java item 18)在这里不起作用)。