package com.app.framework.core.support.enums.data;

import com.app.framework.core.support.enums.BaseEnum;

import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 存储枚举数据
 */
public class EnumItemPool {

    private EnumItemPool() {}

    /**
     * 用于存储枚举数据
     */
    private static final Map<BaseEnum, EnumItem> enumItemMap = new ConcurrentHashMap<>();

    /**
     * 往 map 中添加枚举项
     */
    public static <K extends Serializable> void putEnumItem(BaseEnum baseEnum, K value, String label) {
        enumItemMap.put(baseEnum, new EnumItem(value, label));
    }

    /**
     * 获取静态数据
     */
    public static EnumItem getEnumItem(BaseEnum baseEnum) {
        return enumItemMap.get(baseEnum);
    }

}
