package com.ruoyi.common.enums;

/**
 * 0未分配，1已分配，2已激活，9已失效
 */
public enum CardStatus {
    undistributed(0, "未分配"),
    distributed(1, "已分配"),
    actived(2, "已激活"),
    expired(9, "已失效"),
    closed(10,"已关卡")
    ;

    private Integer value;
    private String remark;

    private CardStatus(Integer value, String remark) {
        this.value = value;
        this.remark = remark;
    }

    public Integer getValue() {
        return value;
    }

    public String getRemark() {
        return remark;
    }

    public static CardStatus getByValue(String value) {
        for (CardStatus o : CardStatus.values()) {
            if (o.getValue().equals(value)) {
                return o;
            }
        }
        return null;
    }

    public static Boolean isUndistributed(Object value) {
        if(value instanceof String){
            if (undistributed.name().equalsIgnoreCase(String.valueOf(value).trim())) {
                return true;
            }
        }

        if(value instanceof Long){
            if (undistributed.getValue().longValue()==Long.valueOf(String.valueOf(value).trim()).longValue()) {
                return true;
            }
        }

        if(value instanceof Integer){
            if (undistributed.getValue().intValue()==Integer.valueOf(String.valueOf(value).trim()).intValue()) {
                return true;
            }
        }

        return false;
    }

    public static Boolean isDistributed(Object value) {
        if(value instanceof String){
            if (distributed.name().equalsIgnoreCase(String.valueOf(value).trim())) {
                return true;
            }
        }

        if(value instanceof Long){
            if (distributed.getValue().longValue()==Long.valueOf(String.valueOf(value).trim()).longValue()) {
                return true;
            }
        }

        if(value instanceof Integer){
            if (distributed.getValue().intValue()==Integer.valueOf(String.valueOf(value).trim()).intValue()) {
                return true;
            }
        }

        return false;
    }

    public static Boolean isActived(Object value) {
        if(value instanceof String){
            if (actived.name().equalsIgnoreCase(String.valueOf(value).trim())) {
                return true;
            }
        }

        if(value instanceof Long){
            if (actived.getValue().longValue()==Long.valueOf(String.valueOf(value).trim()).longValue()) {
                return true;
            }
        }

        if(value instanceof Integer){
            if (actived.getValue().intValue()==Integer.valueOf(String.valueOf(value).trim()).intValue()) {
                return true;
            }
        }

        return false;
    }

    public static Boolean isExpired(Object value) {
        if(value instanceof String){
            if (expired.name().equalsIgnoreCase(String.valueOf(value).trim())) {
                return true;
            }
        }

        if(value instanceof Long){
            if (expired.getValue().longValue()==Long.valueOf(String.valueOf(value).trim()).longValue()) {
                return true;
            }
        }

        if(value instanceof Integer){
            if (expired.getValue().intValue()==Integer.valueOf(String.valueOf(value).trim()).intValue()) {
                return true;
            }
        }

        return false;
    }

    public static Boolean isClosed(Object value) {
        if(value instanceof String){
            if (closed.name().equalsIgnoreCase(String.valueOf(value).trim())) {
                return true;
            }
        }

        if(value instanceof Long){
            if (closed.getValue().longValue()==Long.valueOf(String.valueOf(value).trim()).longValue()) {
                return true;
            }
        }

        if(value instanceof Integer){
            if (closed.getValue().intValue()==Integer.valueOf(String.valueOf(value).trim()).intValue()) {
                return true;
            }
        }

        return false;
    }


}
