package com.unibuy.smartdevice.tools;

import com.unibuy.smartdevice.SchedulerAbstract;
import com.unibuy.smartdevice.exception.ErrorCode;

public abstract class HandlerMainAdpter extends SchedulerAbstract {
    private HandlerMain handlerMain;
    private HandlerMain srcHandlerMain;

    public HandlerMainAdpter(HandlerMain srcHandlerMain) {
        this.srcHandlerMain = srcHandlerMain;
        this.handlerMain = setHandlerMain();
    }

    @Override
    protected void execute() {
        execute(handlerMain);
    }

//    @Override
//    protected void exception(ErrorCode errorCode, String message) {
//        exception(errorCode, message, handlerMain);
//    }

    public HandlerMain getSrcHandlerMain() {
        return srcHandlerMain;
    }

    public HandlerMain getHandlerMain() {
        return handlerMain;
    }

    protected abstract HandlerMain setHandlerMain();
    protected abstract void execute(HandlerMain handlerMain);
    protected abstract void close(HandlerMain handlerMain);
//    protected void exception(ErrorCode errorCode, String message, HandlerMain handlerMain) {
//        handlerMain.error(getClass().getSimpleName(), errorCode, message);
//    }

    @Override
    protected String description() {
        return setCls().getSimpleName();
    }
}
