public StatMap<K> merge(K key, int value) {
    if (key.getType() == Type.LONG) {
      merge(key, (long) value);
      return this;
    }
    int oldValue = getInt(key);
    int newValue = key.merge(oldValue, value);
    if (newValue == 0) {
      _map.remove(key);
    } else {
      _map.put(key, newValue);
    }
    return this;
  }
@Test
  public void encodeDecodeAll()
      throws IOException {
    StatMap<MyStats> statMap = new StatMap<>(MyStats.class);
    for (MyStats stat : MyStats.values()) {
      switch (stat.getType()) {
        case BOOLEAN:
          statMap.merge(stat, true);
          break;
        case INT:
          statMap.merge(stat, 1);
          break;
        case LONG:
          statMap.merge(stat, 1L);
          break;
        case STRING:
          statMap.merge(stat, "foo");
          break;
        default:
          throw new IllegalStateException();
      }
    }
    testSerializeDeserialize(statMap);
  }