@Test public void testEquals() throws Exception { ValueMap map1 = ValueMap.map("1", 1, "2", 2); ValueMap map2 = ValueMap.map("1", 1, "2", 2); ValueMap map3 = ValueMap.map("1", 1, "3", 2); ValueMap map4 = ValueMap.map("1", 1); assertTrue(map1.equals(map2)); assertFalse(map1.equals(map3)); assertFalse(map1.equals(map4)); assertTrue(ValueMap.empty().equals(ValueMap.empty())); assertTrue(ValueMap.map(null, null).equals(ValueMap.map(null, null))); assertFalse(map1.equals(1)); }
@Override public boolean equals(Object other) { if (!(other instanceof ValueMap)) return false; Map<String, Object> otherMap = ((ValueMap)other).map; if (map.size() != otherMap.size()) return false; for (Map.Entry<String, Object> entry : map.entrySet()) { Object value = entry.getValue(); Object otherValue = otherMap.get(entry.getKey()); if (value != otherValue && (value == null || !value.equals(otherValue))) return false; } return true; }
ValueMap implements Parcelable { @Override public boolean equals(Object other) { if (!(other instanceof ValueMap)) return false; Map<String, Object> otherMap = ((ValueMap)other).map; if (map.size() != otherMap.size()) return false; for (Map.Entry<String, Object> entry : map.entrySet()) { Object value = entry.getValue(); Object otherValue = otherMap.get(entry.getKey()); if (value != otherValue && (value == null || !value.equals(otherValue))) return false; } return true; } }
ValueMap implements Parcelable { @Override public boolean equals(Object other) { if (!(other instanceof ValueMap)) return false; Map<String, Object> otherMap = ((ValueMap)other).map; if (map.size() != otherMap.size()) return false; for (Map.Entry<String, Object> entry : map.entrySet()) { Object value = entry.getValue(); Object otherValue = otherMap.get(entry.getKey()); if (value != otherValue && (value == null || !value.equals(otherValue))) return false; } return true; } ValueMap(Map<String, Object> map); protected  ValueMap(Parcel in); }
ValueMap implements Parcelable { @Override public boolean equals(Object other) { if (!(other instanceof ValueMap)) return false; Map<String, Object> otherMap = ((ValueMap)other).map; if (map.size() != otherMap.size()) return false; for (Map.Entry<String, Object> entry : map.entrySet()) { Object value = entry.getValue(); Object otherValue = otherMap.get(entry.getKey()); if (value != otherValue && (value == null || !value.equals(otherValue))) return false; } return true; } ValueMap(Map<String, Object> map); protected  ValueMap(Parcel in); static ValueMap empty(); static Builder builder(); static ValueMap map(Object... map); Set<String> keys(); boolean containsKey(String key); T get(String key); T get(String key, T defaultValue); Builder toBuilder(); @Override void writeToParcel(Parcel dest, int flags); @Override int describeContents(); @Override boolean equals(Object other); @Override int hashCode(); }
ValueMap implements Parcelable { @Override public boolean equals(Object other) { if (!(other instanceof ValueMap)) return false; Map<String, Object> otherMap = ((ValueMap)other).map; if (map.size() != otherMap.size()) return false; for (Map.Entry<String, Object> entry : map.entrySet()) { Object value = entry.getValue(); Object otherValue = otherMap.get(entry.getKey()); if (value != otherValue && (value == null || !value.equals(otherValue))) return false; } return true; } ValueMap(Map<String, Object> map); protected  ValueMap(Parcel in); static ValueMap empty(); static Builder builder(); static ValueMap map(Object... map); Set<String> keys(); boolean containsKey(String key); T get(String key); T get(String key, T defaultValue); Builder toBuilder(); @Override void writeToParcel(Parcel dest, int flags); @Override int describeContents(); @Override boolean equals(Object other); @Override int hashCode(); static final Creator<ValueMap> CREATOR; }