package com.xzzn.common.enums;

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

/**
 * 设备点位类型
 */
public enum PointType
{
    YES(1, "是"),
    NO(0, "否");

    private final Integer code;
    private final String info;

    private static final Map<Integer, String> CODE_NAME_MAP  = new HashMap<>(PointType.values().length);

    static {
        Arrays.stream(PointType.values()).forEach(record -> {
            CODE_NAME_MAP.put(record.code, record.info);
        });
    }

    PointType(Integer code, String info)
    {
        this.code = code;
        this.info = info;
    }

    public String getInfoByCode(Integer code) {
        return CODE_NAME_MAP.get(code);
    }

    public Integer getCode()
    {
        return code;
    }

    public String getInfo()
    {
        return info;
    }
}
