@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Bar other = (Bar) obj; if (i == other.i && s.equals(other.s) && barbar.equals(other.barbar)) return true; else return false; }
@Override public String toString() { try { JSONObject jsonObj = new JSONObject(); jsonObj.put("i", i); jsonObj.put("s", s); JSONObject barbarObj = new JSONObject(barbar.toString()); jsonObj.put("barbar", barbarObj); return jsonObj.toString(); } catch (JSONException e) { throw new RuntimeException("failed to construct JSONObject for toString", e); } }