/** * Instantiates a ToggleableFlag associated with the specified MineFlag and adds it to the list * * @param type Flag type * @throws InvalidFlagException Thrown if an error occurs while instantiating a ToggleableFlag */ public void put(MineFlag type) throws InvalidFlagException { try { ToggleableFlag instance = type.getFlag().newInstance(); flags.put(type, instance); } catch (Throwable t) { throw new InvalidFlagException("Attempted to add an invalid flag", t); } }
/** * De-serializing constructor * * @param map Serialization map */ public CompiledFlagList(Map<String, Object> map) { flags = new HashMap<MineFlag, ToggleableFlag>(); Iterator it = map.values().iterator(); while (it.hasNext()) { Map.Entry value = (Map.Entry) it.next(); flags.put(MineFlag.valueOf((String) value.getKey()), (ToggleableFlag) value.getValue()); } }