package com.zcxk.rmcp.api.enums;

import io.swagger.models.auth.In;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author linqingwei
 * @date 2021-07-20 11:40
 */
@Getter
public enum DeviceStatusEnum {

    /**
     * 正常
     */
    NORMAL(1, "正常"),

    /**
     * 离线
     */
    OFFLINE(2 , "离线"),

    /**
     * 报警
     */
    ALARM(3, "报警"),

    /**
     * 未启用
     */
    UNUSED(4, "未启用"),
    ;

    /**
     * code
     */
    private final Integer code;

    /**
     * 值
     */
    private final String message;


    DeviceStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMessage(String code) {
        Optional<DeviceStatusEnum> optional = Arrays.stream(DeviceStatusEnum.values())
                .filter(p -> p.getCode() == Integer.parseInt(code))
                .findFirst();
        return optional.get().getMessage();
    }
}
