@Override
 public int hashCode() {
   int result = fields != null ? fields.hashCode() : 0;
   result = 31 * result + (type != null ? type.hashCode() : 0);
   result = 31 * result + (connections != null ? connections.hashCode() : 0);
   return result;
 }
 public MetadataImpl(JSONObject json) throws FacebookException {
   try {
     if (!json.isNull("fields")) {
       JSONArray fieldsJSONArray = json.getJSONArray("fields");
       for (int i = 0; i < fieldsJSONArray.length(); i++) {
         JSONObject fieldJSONObject = fieldsJSONArray.getJSONObject(i);
         fields.add(new MetadataFieldImpl(fieldJSONObject));
       }
     }
     if (!json.isNull("type")) {
       type = json.getString("type");
     }
     if (!json.isNull("connections")) {
       JSONObject connectionsJSONObject = json.getJSONObject("connections");
       @SuppressWarnings("unchecked")
       Iterator<String> fieldNamesIterator = connectionsJSONObject.keys();
       while (fieldNamesIterator.hasNext()) {
         String key = fieldNamesIterator.next();
         String value = connectionsJSONObject.getString(key);
         connections.put(key, value);
       }
     }
   } catch (JSONException e) {
     throw new FacebookException(e);
   }
 }
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      MetadataImpl metadata = (MetadataImpl) o;

      if (fields != null ? !fields.equals(metadata.fields) : metadata.fields != null) return false;
      if (type != null ? !type.equals(metadata.type) : metadata.type != null) return false;
      return connections != null
          ? connections.equals(metadata.connections)
          : metadata.connections == null;
    }