我有一个父抽象类和采用泛型的子类。
public abstract sealed class Parent<T> permits ChildA, ChildB {}
public non-sealed class ChildA<T extends FileTypeA> extends Parent{}
public non-sealed class ChildB<T extends FileTypeB> extends Parent{}
在父类中,我收到警告:
ChildA is a raw type. References to generic type ChildA<T>
should be parameterized
ChildB is a raw type. References to generic type ChildB<T>
should be parameterized
在子类中,我收到警告:
Parent is a raw type. References to generic type Parent<T>
should be parameterized
使它们像这样参数化:
public abstract sealed class Parent<T>
permits ChildA<T extends FileTypeA>, ChildB<T extends FileTypeB> {}
甚至
public abstract sealed class Parent<T>
permits ChildA<T>, ChildB<T> {}
给出错误:
Bound mismatch: The type T is not a valid substitute for the
bounded parameter <T extends FileTypeA> of the type ChildA<T>
如何删除这些警告和错误?