package cn.estsh.i3plus.pojo.mes.pcn.model;


import io.swagger.annotations.Api;
import lombok.Data;

import java.util.Collection;

@Data
@Api("工步返回信息")
public class StepResult<T> {

    private boolean isCompleted;

    private T data;

    private Collection<T> dataCollection;

    private String msg;

    public static StepResult getSuccessComplete() {
        return new StepResult(true, "");
    }

    public static StepResult getNonComplete() {
        return new StepResult(false, "");
    }

    public static StepResult getSuccessComplete(String msg) {
        return new StepResult(true, msg);
    }

    public static StepResult getNonComplete(String msg) {
        return new StepResult(false, msg);
    }

    public static <T> StepResult<T> getSuccessData(T data, String msg) {
        return new StepResult<>(true, data, msg);
    }

    public static <T> StepResult<T> getSuccessData(Collection<T> data, String msg) {
        return new StepResult<T>(true, data, msg);
    }

    private StepResult() {
    }

    private StepResult(boolean isCompleted) {
        this.isCompleted = isCompleted;
    }

    private StepResult(boolean isCompleted, String msg) {
        this.isCompleted = isCompleted;
        this.msg = msg;
    }

    public StepResult(boolean isCompleted, T data, String msg) {
        this.isCompleted = isCompleted;
        this.data = data;
        this.msg = msg;
    }

    public StepResult(boolean isCompleted, Collection<T> dataCollection, String msg) {
        this.isCompleted = isCompleted;
        this.dataCollection = dataCollection;
        this.msg = msg;
    }

}
