首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与通用类型的接口-它是否已经被工程化了?

与通用类型的接口-它是否已经被工程化了?
EN

Stack Overflow用户
提问于 2021-01-13 15:28:38
回答 1查看 60关注 0票数 0

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

这是接口声明

代码语言:javascript
复制
public interface EmployeeMother<EmployeeMotherT extends EmployeeMother, EmpTargetT>{

    EmployeeMotherT fromJsonSchema();
    
    EmployeeMotherT withCompleteDetails();
    
    EmpTargetT> build();
}

这个<EmployeeMotherT extends EmployeeMother, EmpTargetT>是什么意思?

下面是这个接口的实现。

代码语言:javascript
复制
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>在实现类中意味着什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-13 15:54:22

<EmployeeMotherT extends EmployeeMother, EmpTargetT>是什么意思?

<EmployeeMotherT extends EmployeeMother, EmpTargetT>意味着涉及两种泛型:

扩展了

  • EmployeeMotherT的EmployeeMother
  • EmpTargetT

,这个implements EmployeeMother<EmployeeFormMother,EmployeeForm>在实现类中意味着什么?

这意味着这个类将为接口中定义的方法桩提供具体的实现。这还意味着,在这种情况下,EmployeeFormMother必须是EmployeeMother的一个子类型,也意味着EmployeeFormEmpTargetT的一个子类型。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65704939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档