private static BasicBSONObject canonicalizeBSONObject(final BSONObject from) { final BasicBSONObject canonicalized = new BasicBSONObject(); final TreeSet<String> keysInOrder = new TreeSet<String>(from.keySet()); for (final String key : keysInOrder) { final Object val = from.get(key); canonicalized.put(key, canonicalize(val)); } return canonicalized; }
public boolean equals(final Object o) { if (o == this) { return true; } if (!(o instanceof BSONObject)) { return false; } final BSONObject other = (BSONObject) o; return ((HashMap<String, V>) this).keySet().equals(other.keySet()) && Arrays.equals( canonicalizeBSONObject(this).encode(), canonicalizeBSONObject(other).encode()); }
public void putAll(final BSONObject o) { for (final String k : o.keySet()) { this.put(k, o.get(k)); } }