package com.fizz.business.constants.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * websocket type
 *
 * @author chenhao
 * @date 2023/04/24
 */
@Getter
@AllArgsConstructor
public enum WsTypeEnum {
    alarm, track_position, track_measure, track_signal, track_matmap,calc_setup_result;

    private static final Map<String, WsTypeEnum> MAP = new HashMap<>(8);

    static {
        for (WsTypeEnum e : WsTypeEnum.values()) {
            MAP.put(e.getValue(), e);
        }
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static WsTypeEnum getByValue(String value) {
        return MAP.get(value);
    }

    @JsonValue
    public String getValue() {
        return this.name();
    }
}
