Java:模板类型的递归定义

时间:2018-09-20 09:35:37

标签: java oop generics

看看这个类的声明:

public abstract class AbstractTargetBuilder<T extends AbstractTargetBuilder<T, S>, S extends Target> {
...
}

类型T被定义为AbstractTargetBuilder<T,S>的子类型。这种模式有什么用?

此代码属于Spotlight库: https://github.com/TakuSemba/Spotlight/blob/master/spotlight/src/main/java/com/takusemba/spotlight/target/AbstractTargetBuilder.java

0 个答案:

没有答案