Storage
メソッドをまだ定義しているfind
(そしてメソッドを使用していない)ため、定義する間は同じ署名を保持します。
Storage implements IStorage {
<T extends ICommon> Collection<T> find(String name, boolean isExact) {
//some code
}
}
そのジェネリックメソッドを実際に呼び出すときに、具象型パラメーターを指定します。
Storage s = new Storage();
s.<IOrganization>find("hello world", true);
ただし、ジェネリックメソッドでT
導入するパラメータタイプ<T extends ICommon>
は、パラメータリストにないため、役に立ちません。
おそらくあなたが望むのは一般的な方法ではないかもしれません。しかし、次のようなものです。
interface IStorage {
public Collection<? extends ICommon> find(String name, boolean isExact);
}
//and
class Storage implements IStorage {
public Collection<IOrganization> find(String name, boolean isExact) {
//some code
}
}
//or
class Storage implements IStorage {
public Collection<? extends ICommon> find(String name, boolean isExact) {
//some code
}
}