package com.ywt.outpatient.domain.models.enums;

/**
 * @author Walker
 * Created on 2021/1/25
 */
public enum NatOrderStatusEnum {

    UNKNOWN("", 0),
    UNPAID("未支付", 1),
    PAID("待检测", 2),
    FINISHED("已完成", 4),
    CANCELED("已取消", 8),
    REFUNDED("已退款", 16),
    ;

    private final String displayName;

    private final int value;

    NatOrderStatusEnum(String displayName, int value) {
        this.displayName = displayName;
        this.value = value;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    public static NatOrderStatusEnum valueOf(int value) {
        for (NatOrderStatusEnum e : NatOrderStatusEnum.values()) {
            if ((value & e.getValue()) == e.getValue() && value < 2 * e.getValue()) {
                return e;
            }
        }
        return UNKNOWN;
    }
}