package com.crm.rely.backend.core.enums;

/**
 * 组别类型
 *
 * @author y
 * @create 2022/1/21
 */
public enum SymbolType {

    FX(1L, "FX"), CFD(2L, "CFD"), INDEX(3L, "INDEX"), METAL(4L, "METAL");


    private final Long code;
    private final String desc;

    SymbolType(Long code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Long getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static SymbolType matchCode(Long code) {
        for (SymbolType type : SymbolType.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }

    public static Boolean exists(Long code, String desc) {
        SymbolType customGroupType = matchCode(code);
        if (customGroupType == null) {
            return false;
        }

        if (customGroupType.getDesc().equals(desc)) {
            return true;
        } else {
            return false;
        }

    }


}
