与通用类型的接口 - 是否过度设计?

Interface with generic type - is it over engineered?

我们在现有代码中有一个接口让我感到困惑,或者我无法正确理解它。

这是接口声明

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>在实施中是什么意思class?

What does this <EmployeeMotherT extends EmployeeMother, EmpTargetT> mean?

<EmployeeMotherT extends EmployeeMother, EmpTargetT>表示涉及两个泛型:

  • EmployeeMotherT 扩展了 EmployeeMother
  • EmpTargetT

what does this implements EmployeeMother<EmployeeFormMother,EmployeeForm> mean in the implementing class?

这意味着这个class将为接口中定义的方法树桩提供具体的实现。这也意味着在这种情况下 EmployeeFormMother 必须是 EmployeeMother 的子类型,并且 EmployeeForm 必须是 EmpTargetT.

的子类型