我需要在子类中重写父类中的非抽象方法吗?这个非抽象方法是在接口中定义的

问题描述 投票:0回答:1

我有一个界面

public interface PushRequest {
    void setId(int var1);

    void setSysCode(String var1);

    void setServerURL(String var1);

    void setWorkflowWhitelist(ArrayList<String> var1);

    void setUserWhitelist(ArrayList<String> var1);

    void pushData(OfsPushRequestData var1);
}

我的抽象类实现了接口

public abstract class TodoSend implements PushRequest {
    public int id;
    public String syscode;
    public String serverurl;
    public ArrayList<String> workflowwhitelist;
    public ArrayList<String> userwhitelist;
    protected String workflowPcUrl;
    protected String workflowMobileUrl;

    public TodoSend() {
        this.workflowPcUrl = this.serverurl + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid=";
        this.workflowMobileUrl = this.serverurl + "/spa/workflow/static4mobileform/index.html?#/req?requestid=%s&f_weaver_belongto_userid=%s";
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setSysCode(String syscode) {
        this.syscode = syscode;
    }

    public void setServerURL(String serverurl) {
        this.serverurl = serverurl;
    }

    public void setWorkflowWhitelist(ArrayList<String> arrayList) {
        this.workflowwhitelist = arrayList;
    }

    public void setUserWhitelist(ArrayList<String> arrayList) {
        this.workflowwhitelist = arrayList;
    }

    public void pushData(OfsPushRequestData ofsPushRequestData) {
        ArrayList<DataObj> dataObjList = ofsPushRequestData.getDataObjList();
        Iterator var3 = dataObjList.iterator();

        while(true) {
            ArrayList deldatas;
            do {
                if (!var3.hasNext()) {
                    return;
                }

                DataObj dataObj = (DataObj)var3.next();
                ArrayList<RequestStatusObj> tododatas = dataObj.getTododatas();
                if (CollUtil.isNotEmpty(tododatas)) {
                    Iterator var6 = tododatas.iterator();

                    while(var6.hasNext()) {
                        RequestStatusObj tododata = (RequestStatusObj)var6.next();
                        this.todoPush(tododata);
                    }
                }

                ArrayList<RequestStatusObj> donedatas = dataObj.getDonedatas();
                if (CollUtil.isNotEmpty(donedatas)) {
                    Iterator var11 = donedatas.iterator();

                    while(var11.hasNext()) {
                        RequestStatusObj doneData = (RequestStatusObj)var11.next();
                        this.donePush(doneData);
                    }
                }

                deldatas = dataObj.getDeldatas();
            } while(!CollUtil.isNotEmpty(deldatas));

            Iterator var13 = deldatas.iterator();

            while(var13.hasNext()) {
                RequestStatusObj deldata = (RequestStatusObj)var13.next();
                this.delPush(deldata);
            }
        }
    }

    public abstract void todoPush(RequestStatusObj var1);

    public abstract void donePush(RequestStatusObj var1);

    public abstract void delPush(RequestStatusObj var1);
}

我的类继承了抽象类

public class TodoSendImpl extends TodoSend {
    
    @Override
    public void todoPush(RequestStatusObj requestStatusObj) {
        
    }

    @Override
    public void donePush(RequestStatusObj requestStatusObj) {
        
    }

    @Override
    public void delPush(RequestStatusObj requestStatusObj) {
       
    }
}

但我的想法告诉我出了问题 类“TodoSendImpl”必须声明为抽象或在“PushRequest”中实现抽象方法“setWorkflowWhitelist(ArrayList)” enter image description here

setWorkflowWhitelist 不是已经在抽象类中实现了吗

我还需要在TodoSendImpl类中实现吗

TodoSendImpl 类中没有实现 setWorkflowWhitelist 方法,仅在抽象类中实现

java class inheritance abstract
1个回答
0
投票

不,根本不强制实现(在子类中)已经实现的方法(在抽象类中)。请检查代码中的类型错误。

© www.soinside.com 2019 - 2024. All rights reserved.