package net.northking.cctp.upperComputer.automation.entity;

import java.io.Serializable;

/**
 * @author : yineng.huang
 * @date : 2024/4/17 0:56
 */
public class CmdAutomationResponse implements Serializable {

    private String serial;

    private String cmd;

    private String stepToken;  //匹配执行步骤

    private boolean success;

    private String message;

    private boolean finish;

    private Object data;

    public static CmdAutomationResponse builderSuccess(CmdAutomationRequest request,String message){
        return newResponse().cmd(request.getCmd())
                .isSuccess(true)
                .withToken(request.getStepToken())
                .withMessage(message)
                .finish(true);
    }

    public static CmdAutomationResponse builderFailure(CmdAutomationRequest request,String message){
        return newResponse().cmd(request.getCmd())
                .isSuccess(false)
                .withToken(request.getStepToken())
                .withMessage(message)
                .serial(request.getSerial())
                .finish(true);
    }

    public CmdAutomationResponse withData(Object data) {
        this.data = data;
        return this;
    }

    public CmdAutomationResponse serial(String serial) {
        this.serial = serial;
        return this;
    }

    private CmdAutomationResponse finish(boolean finish) {
        this.finish = finish;
        return this;
    }

    private CmdAutomationResponse withMessage(String message) {
        this.message = message;
        return this;
    }

    private CmdAutomationResponse withToken(String stepToken) {
        this.stepToken = stepToken;
        return this;
    }

    private static CmdAutomationResponse newResponse(){
        return new CmdAutomationResponse();
    }

    private CmdAutomationResponse cmd(String cmd){
        this.cmd = cmd;
        return this;
    }

    private CmdAutomationResponse isSuccess(boolean success){
        this.success = success;
        return this;
    }

    public String getStepToken() {
        return stepToken;
    }

    public String getSerial() {
        return serial;
    }

    public String getCmd() {
        return cmd;
    }

    public boolean isSuccess() {
        return success;
    }

    public String getMessage() {
        return message;
    }

    public boolean isFinish() {
        return finish;
    }

    public Object getData() {
        return data;
    }

    public void setSerial(String serial) {
        this.serial = serial;
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }

    public void setStepToken(String stepToken) {
        this.stepToken = stepToken;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setFinish(boolean finish) {
        this.finish = finish;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
