package com.nanometer.smartlab.entity.enumtype; import java.util.HashMap; public enum RealStatus{ OUT(0, "不在柜"), IN(1, "在柜"); private int key; private String text; private RealStatus(int key, String text) { this.key = key; this.text = text; } public int getKey() { return key; } public String getText() { return text; } private static HashMap map = new HashMap(); static { for(RealStatus d : RealStatus.values()){ map.put(d.key, d); } } public static RealStatus parse(Integer index) { if(map.containsKey(index)){ return map.get(index); } return null; } }