package com.zcxk.rmcp.api.enums;

import lombok.Getter;

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

/**
 * @author linqingwei
 * @date 2021-07-20 11:46
 */
@Getter
public enum ValveStatusEnum {
    /**
     * 关阀
     */
    OFF(0,"关阀"),

    /**
     * 开阀
     */
    ON(1,"开阀"),

    /**
     * 异常
     */
    ABNORMAL(2,"异常"),
    ;

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

    /**
     * 消息
     */
    private final String message;


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

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

}
