예제 #1
0
  public static Map<BotLevel, Integer> deserializeBots(JSONObject botsArray) {
    if (botsArray == null) return null;

    Map<BotLevel, Integer> bots = new HashMap<BotLevel, Integer>();
    for (BotLevel l : BotLevel.values()) {
      if (botsArray.has(l.name())) bots.put(l, botsArray.getInt(l.name()));
    }

    return bots;
  }
예제 #2
0
  public static JSONObject serializeBots(Map<BotLevel, Integer> bots) {
    if (bots == null) return null;

    JSONObject botArray = new JSONObject();
    for (BotLevel l : BotLevel.values()) {
      Integer n = bots.get(l);
      if (n != null && n != 0) botArray.put(l.name(), n.intValue());
    }
    return botArray;
  }