我的界面层次结构有问题。我的项目在刚性结构中有四个类和六个接口,即:
public interface Set<T, N extends Settable<T,N>>
public interface Settable<T, N>
public interface Sequence<T, N extends Sequenceable<T,N>> extends Set<T,N>
public interface Sequenceable<T,N> extends Settable<T,N>
public interface DisjoinedSet<T, N extends DisjoinedSettable<T,N>> extends Set<T,N>
public interface DisjoinedSettable<T,N> extends Settable<T,N>
public class List<T> implements Sequence<T, NodeList<T>>
public class NodeList<T> implements Sequenceable<T,NodeList<T>>
public class ListDisjoined<T> extends List<T> implements DisjoinedSet<T,NodeListDisjoined<T>>, Sequence<T,NodeListDisjoined<T>>
public class NodeListDisjoined<T> extends List<T> implements DisjoinedSettable<T,NodeListDisjoined<T>>, Sequenceable<T,NodeListDisjoined<T>>
除了可怕的命名之外,我的想法是通过创建容器包含的类/接口对,我获得了大量的sinergy:我可以简单地在接口的注释中编写这些方法的主体并复制和过去一整个班级的早午餐,没有改变任何。
但是,我在最后两节课中遇到两个错误:
The interface Sequence cannot be implemented more than once with different arguments: Sequence<T,NodeList<T>> and Sequence<T,NodeListDisjoined<T>>
The interface Sequenceable cannot be implemented more than once with different arguments: Sequenceable<T,NodeList<T>> and Sequenceable<T,NodeListDisjoined<T>>
NodeListDisjoined
是NodeList
的子类,那么问题是什么?
注意:在此行下编辑的编辑有效。我仍然不明白为什么。
public interface DisjoinedSet<T, N extends DisjoinedSettable<T,N>> extends Sequence<T,N>
public interface DisjoinedSettable<T,N> extends Sequenceable<T,N>