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

/**
 * @author Walker
 * Created on 2021/7/1
 */
public enum MedEquipStatusEnum {

    UNPAID("待支付", 0),
    PAID("已支付", 1),
    ALLOCATED("已领取", 2),
    RECYCLED("已回收", 4),
    REFUNDING("退款申请中", 8),
    REFUNDED("已退款", 16),
    EXPIRED("已过期", 32),
    ;

    private final String displayName;

    private final int value;

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

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

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