Having this design :
interface Foo<T> {
void doSomething(T t);
}
class FooImpl implements Foo<Integer> {
//code...
}
interface Bar extends Foo {
//code...
}
class BarImpl extends FooImpl implements Bar {
//code...
}
It gives me Compile Error :
The interface Foo cannot be
implemented more than once with
different arguments: Foo and
Foo
a simple fix for this issue is :
interface Bar extends Foo<Integer> {
// code...
}
Integer type in Bar interface is totally useless.
is there any better way to solve this issue ?
any better design?
Thanks for your advices.
EDIT:
given solution:
> interface Bar<T> extends Foo<T>
is ok, but its same as my previous solution. i don’t need T type in Bar.
let me give a better sample:
interface ReadOnlyEntity {
}
interface ReadWriteEntity extends ReadOnlyEntity {
}
interface ReadOnlyDAO<T extends ReadOnlyEntity> {
}
interface ReadWriteDAO<K extends ReadWriteEntity, T extends ReadonlyEntity> extends ReadOnlyDAO<T> {
}
is this a good design?
I’d recommend thinking of a type for the Bar generic or rethink your design. If there’s no object that makes sense for Bar, then it shouldn’t be implementing
Foo<T>.EDIT:
No, not in my opinion.