Implement equality for ReadableNativeMap

Summary: This diff implements equality for ReadableNativeMap, the underlying implementation relies on the method HashMap.equals()

Reviewed By: kathryngray

Differential Revision: D14019065

fbshipit-source-id: aeaec22ce1066241ed85f0527f5cd804e3c763dd
This commit is contained in:
David Vacca
2019-02-17 11:03:13 -08:00
committed by Facebook Github Bot
parent a8703fe10b
commit f4536422d6
3 changed files with 89 additions and 1 deletions
@@ -236,6 +236,20 @@ public class ReadableNativeMap extends NativeMap implements ReadableMap {
return new ReadableNativeMapKeySetIterator(this);
}
@Override
public int hashCode() {
return getLocalMap().hashCode();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ReadableNativeMap)) {
return false;
}
ReadableNativeMap other = (ReadableNativeMap) obj;
return getLocalMap().equals(other.getLocalMap());
}
@Override
public @Nonnull HashMap<String, Object> toHashMap() {
if (ReactFeatureFlags.useMapNativeAccessor) {