package com.fs.watch.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum WatchDeviceStatusEnum{

    OFFLINE(0,"offline"),
    ONLINE(1,"online"),
    UNACTIVE(2,"unactive"),
    DISABLE(3,"disable"),
    NOT_EXIST(4,"not exist");


    private Integer value;

    //解析
    private String desc;


    public static WatchDeviceStatusEnum toType(Integer value) {
        return Stream.of(WatchDeviceStatusEnum.values())
                .filter(p -> Objects.equals(p.value, value))
                .findAny()
                .orElse(null);
    }

    public static WatchDeviceStatusEnum toType(String desc) {
        return Stream.of(WatchDeviceStatusEnum.values())
                .filter(p -> Objects.equals(p.desc, desc))
                .findAny()
                .orElse(null);
    }
}
