package cn.axzo.workflow.common.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 加签类型
 *
 * @author zuoqinbo
 */
public enum BpmnCountersignType {
    /**
     * 向前加签
     */
    FORWARD_COUNTERSIGN("FORWARD_COUNTERSIGN", "向前加签"),
    /**
     * 向后加签
     */
    BACK_COUNTERSIGN("BACK_COUNTERSIGN", "向后加签");

    private String type;
    private String desc;

    BpmnCountersignType(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public boolean isEqual(String type) {
        return this.type.equals(type);
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }


    public static BpmnCountersignType isValidAppType(String countersignType) {
        if (StringUtils.isBlank(countersignType)) {
            return null;
        }
        BpmnCountersignType[] countersignTypeEnums = BpmnCountersignType.values();
        for (BpmnCountersignType countersign : countersignTypeEnums) {
            if (countersign.getType().equals(countersignType)) {
                return countersign;
            }
        }
        return null;
    }
}
