有這個設計:
interface Foo {
void doSomething(T t);
}
class FooImpl implements Foo {
//code...
}
interface Bar extends Foo {
//code...
}
class BarImpl extends FooImpl implements Bar {
//code...
}
它給了我編譯錯誤:
The interface Foo cannot be
implemented more than once with
different arguments: Foo and
Foo
解決此問題的簡單方法是:
interface Bar extends Foo {
// code...
}
Bar界面中的整數類型完全沒用.
有沒有更好的方法來解決這個問題?
任何更好的設計?
謝謝你的建議.
編輯:
給定解決方案
> interface Bar extends Foo
沒關系,但和我之前的解決方案一樣.我在Bar中不需要T型.
讓我給出一個更好的樣本:
interface ReadOnlyEntity {
}
interface ReadWriteEntity extends ReadOnlyEntity {
}
interface ReadOnlyDAO {
}
interface ReadWriteDAO extends ReadOnlyDAO {
}
這是一個很好的設計嗎?