package com.fjhx.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 设备类型
 */
@Getter
public enum DeviceTypeEnum {

    HANDHELD_MACHINE(0, "一体机"),
    INTEGRATED_MACHINE(1, "手持机"),
    WEB(2, "web端");

    private final Integer type;
    private final String name;

    private static final HashMap<Integer, DeviceTypeEnum> map = new HashMap<>();
    private static final List<Integer> list = new ArrayList<>();

    DeviceTypeEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    static {
        for (DeviceTypeEnum value : DeviceTypeEnum.values()) {
            map.put(value.getType(), value);
            list.add(value.getType());
        }
    }

    /**
     * 根据type获取枚举
     */
    public static DeviceTypeEnum get(Integer type) {
        return map.get(type);
    }

    /**
     * 根据type值获取枚举
     */
    public static String getName(Integer type) {
        return map.get(type).getName();
    }

    public static List<Integer> list() {
        return list;
    }


}
