我有以下抽象类:
public abstract class PresenterWithBreadCrumb<V extends View> extends PresenterWidget<V> {
...
我想要做的是扩展这个类并修改类型V.除了View接口提供的方法之外,我还需要一种方法。新实例如下。
public abstract class ApplicationPanelPresenter<V extends ApplicationPanelPresenter.ApplicationPanelView>
extends PresenterWithBreadCrumb<ApplicationPanelPresenter.ApplicationPanelView> {
public interface ApplicationPanelView extends View {
void clearPanel();
}
当我尝试重构我的代码,并将最初扩展PresenterWithBreadCrumb
的类更改为ApplicationPanelPresenter
时,我引入了编译错误。
之前的样本:
public class RequirementsPanelPresenter extends PresenterWithBreadCrumb<RequirementsPanelPresenter.MyView>
implements RequirementsPanelUiHandlers {
interface MyView extends View, HasUiHandlers<RequirementsPanelUiHandlers> {
}
@Inject
RequirementsPanelPresenter(EventBus eventBus, MyView view) {
super(eventBus, view);
getView().setUiHandlers(this);
}
示例之后:
public class RequirementsPanelPresenter extends ApplicationPanelPresenter<RequirementsPanelPresenter.MyView>
implements RequirementsPanelUiHandlers {
interface MyView extends ApplicationPanelPresenter.ApplicationPanelView, HasUiHandlers<RequirementsPanelUiHandlers> {
}
@Inject
RequirementsPanelPresenter(EventBus eventBus, MyView view) {
super(eventBus, view);
getView().setUiHandlers(this);
}
编译错误在语句getView().setUiHandlers(this);
编译错误是:
方法setUiHandlers(RequirementsPanelPresenter)未定义 ApplicationPanelPresenter.ApplicationPanelView类型
为什么编译器将“this”解释为ApplicationPanelPresenter.ApplicationPanelView?我的更改是如何引入此错误的,我该如何解决?
附加上下文
getView()
方法在父类中定义,并返回类型V extends View
。
setUiHandlers方法来自扩展接口HasUiHandlers。方法参数是类型C extends UiHandlers
。 RequirementsPanelPresenter正在实施的界面RequirementsPanelUiHandler
,扩展了UiHandlers
。
答案 0 :(得分:1)
乍一看,我希望它是
public abstract class ApplicationPanelPresenter<
V extends ApplicationPanelPresenter.ApplicationPanelView>
extends PresenterWithBreadCrumb<V> {
你的代码太复杂了,我无法一眼就知道是否会修复它。