package com.fuyuanshen.equipment.enums;

/**
 * @author: 默苍璃
 * @date: 2025-06-1918:50
 */
public enum DeviceAuthorizationStatus {
    /**
     * 未授权
     */
    UNAUTHORIZED(0),

    /**
     * 已授权
     */
    AUTHORIZED(1);

    private final int value;

    DeviceAuthorizationStatus(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }

    /**
     * 根据整数值获取对应的枚举值
     *
     * @param value 整数值（0 或 1）
     * @return 对应的 DeviceAuthorizationStatus 枚举
     * @throws IllegalArgumentException 如果值不是 0 或 1
     */
    public static DeviceAuthorizationStatus fromValue(int value) {
        for (DeviceAuthorizationStatus status : values()) {
            if (status.getValue() == value) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid device authorization status value: " + value);
    }

}

