code: public int getSerializedSize() {
      int result = 0;
      for (final Map.Entry<Integer, Field> entry : fields.entrySet()) {
        result += entry.getValue().getSerializedSize(entry.getKey());
      }
      return result;
    }
docs: Get the number of bytes required to encode this set.