我们在现有代码中有一个接口,这让我很困惑,或者我无法正确理解它。
这是接口声明
public interface EmployeeMother<EmployeeMotherT extends EmployeeMother, EmpTargetT>{
EmployeeMotherT fromJsonSchema();
EmployeeMotherT withCompleteDetails();
EmpTargetT> build();
}这个<EmployeeMotherT extends EmployeeMother, EmpTargetT>是什么意思?
下面是这个接口的实现。
public class EmployeeFormMother extends EmployeeFormBuilder<EmployeeForm>
implements EmployeeMother<EmployeeFormMother,EmployeeForm>{
public EmployeeFormMother fromJsonSchema(){
.....
return this;
}
public EmployeeFormMother fromJsonSchema(){
....
return this;
}
public EmployeeFormMother fromJsonSchema(){
return this;
}
public EmployeeForm build(){
...
return super.build();
}
}这个implements EmployeeMother<EmployeeFormMother,EmployeeForm>在实现类中意味着什么?
发布于 2021-01-13 15:54:22
这
<EmployeeMotherT extends EmployeeMother, EmpTargetT>是什么意思?
<EmployeeMotherT extends EmployeeMother, EmpTargetT>意味着涉及两种泛型:
扩展了
,这个
implements EmployeeMother<EmployeeFormMother,EmployeeForm>在实现类中意味着什么?
这意味着这个类将为接口中定义的方法桩提供具体的实现。这还意味着,在这种情况下,EmployeeFormMother必须是EmployeeMother的一个子类型,也意味着EmployeeForm是EmpTargetT的一个子类型。
https://stackoverflow.com/questions/65704939
复制相似问题