子类方法未覆盖其超类通用方法。

huangapple 未分类评论64阅读模式
标题翻译

Subclass method doesn't override its super generic method

问题

以下是翻译好的内容:

在超类中,我有一个通用方法。我想根据子类中的实体类型来重写它。这些代码是用Groovy语言编写的。

protected T fromEntity(E entity) {
    return entity
}

我想在子类中重写这个方法。这应该是要重写的方法之一:

@Override
protected FactorInfo fromEntity(Factor f) {
    // 从f中提取并返回FactorInfo
    return new FactorInfo()
}

但是我的IDE显示:

方法未覆盖其超类中的方法。

为什么这个方法没有覆盖超类方法?

英文翻译

I have a generic method in the super class. I want to override this based on entity type in subclasses. These codes are written in groovy language.

 protected T fromEntity(E entity) {
     return entity
 }

I want to override this method in my subclass. This is supposed to be one of the overridden methods:

@Override
protected FactorInfo fromEntity(Factor f) {
    // extract and return FactorInfo from f
    return new FactorInfo()
}

But my IDE says:

> Method does not override method from its super class.

Why this method doesn't override the super method?

huangapple
  • 本文由 发表于 2020年1月30日 19:38:05
  • 转载请务必保留本文链接:https://java.coder-hub.com/59985195.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定