ここでは、私が取り組んでいるオブジェクトモデルの簡略化されたバージョンを示します。ジェネリック編集エラー:型引数が型変数の境界内にないS
public class GenericsTest {
public interface FooInterface {
public void foo();
}
public class Bar implements FooInterface {
public void foo() {}
}
public interface GenericInterface <T> {
public T func1();
}
public class Service implements GenericInterface<Bar> {
@Override
public Bar func1() {
return null;
}
}
public class GenericBar <S extends GenericInterface<FooInterface>> {
public S s;
public GenericBar() {}
}
public static void main(String[] args) {
GenericBar<Service> serviceGenericBar; // <-- compilation error at this line
<... more code ...>
}
}
コンパイラエラー:type argument GenericsTest.Service is not within bounds of type-variable S
IDE(IntelliJのは)エラーのいくつかの詳細を示していますType parameter 'GenericsTest.Service' is not within its bound; should implement GenericsTest.GenericInterface<GenericTests.FooInterface>
Service
クラスはGenericInterfaceを実施しています。私は同じエラーでいくつかの他のSOの質問を見てきましたが、この特定のシナリオの手がかりを提供していません。どのようにこれを修正するための任意のアイデア?
GenericBarインプリメンテーションを共有する – StackFlowed