我有一个 BatchConfigurable 类
public class BatchConfigurable<T extends BatchContext>() {}
我正在尝试为其编写一个包装器。这将是另一个类,它采用此类或任何扩展 BatchConfigurable 的类作为参数。对于声明,我正在尝试:
public class WrappedBatchConfigurable<E extends BatchConfigurable <T extends BatchContext>>() {}
这是无效的,但从代码中应该可以清楚地看出,我想保留 WrappedBatchConfigurable 所采用的 BatchConfigurable 子类型应该采用扩展 BatchContext 作为参数的类型的属性。其语法是什么?
最佳答案
在使用之前,您需要声明类型参数T
。
class WrappedBatchConfigurable<T extends BatchContext, E extends BatchConfigurable<T>> {}
关于Java 泛型 : Class that takes a class that takes another class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38987324/