package com.market.enums;

import java.util.Arrays;

/**
 * 前端 WS topic 类型
 */
public enum WsTopicType {

    TRADE("trade"),
    TICKET("ticket"),
    MARK("mark"),
    DEPTH("depth"),
    KLINE("kline");

    private final String code;

    WsTopicType(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public static WsTopicType fromCode(String code) {
        return Arrays.stream(values())
                .filter(value -> value.code.equals(code))
                .findFirst()
                .orElse(null);
    }
}
