标题翻译
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?
专注分享java语言的经验与见解,让所有开发者获益!
评论