protected BaseEnum getById(Class clz, int id) { List list = getAll(clz); int size = (list == null ? 0 : list.size()); for (int i = 0; i < size; i++) { BaseEnum e = (BaseEnum) list.get(i); if (e.getId() == id) { return e; } } return null; }
public void addEnum(BaseEnum baseEnum) { List<BaseEnum> list = s_enumMap.get(baseEnum.getClass()); if (list == null) { list = new ArrayList<BaseEnum>(); s_enumMap.put(baseEnum.getClass(), list); } int size = list.size(); for (int i = 0; i < size; i++) { BaseEnum e = list.get(i); if (e.getId() == baseEnum.getId()) { throw new RuntimeException( "ID(" + baseEnum.getId() + ") has already been used by " + e + " in " + baseEnum.getClass()); } } list.add(baseEnum); }