@Test public void testEquals() { DocumentSnapshot base = TestUtil.documentSnapshot("rooms/foo", map("a", 1), false); DocumentSnapshot baseDup = TestUtil.documentSnapshot("rooms/foo", map("a", 1), false); DocumentSnapshot noData = TestUtil.documentSnapshot("rooms/foo", null, false); DocumentSnapshot noDataDup = TestUtil.documentSnapshot("rooms/foo", null, false); DocumentSnapshot differentPath = TestUtil.documentSnapshot("rooms/bar", map("a", 1), false); DocumentSnapshot differentData = TestUtil.documentSnapshot("rooms/foo", map("b", 1), false); DocumentSnapshot fromCache = TestUtil.documentSnapshot("rooms/foo", map("a", 1), true); assertEquals(base, baseDup); assertEquals(noData, noDataDup); assertNotEquals(base, noData); assertNotEquals(noData, base); assertNotEquals(base, differentPath); assertNotEquals(base, differentData); assertNotEquals(base, fromCache); assertEquals(base.hashCode(), baseDup.hashCode()); assertEquals(noData.hashCode(), noDataDup.hashCode()); assertNotEquals(base.hashCode(), noData.hashCode()); assertNotEquals(noData.hashCode(), base.hashCode()); assertNotEquals(base.hashCode(), differentPath.hashCode()); assertNotEquals(base.hashCode(), fromCache.hashCode()); }
@Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof DocumentSnapshot)) { return false; } DocumentSnapshot other = (DocumentSnapshot) obj; return firestore.equals(other.firestore) && key.equals(other.key) && (doc == null ? other.doc == null : doc.equals(other.doc)) && metadata.equals(other.metadata); }
DocumentSnapshot { @Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof DocumentSnapshot)) { return false; } DocumentSnapshot other = (DocumentSnapshot) obj; return firestore.equals(other.firestore) && key.equals(other.key) && (doc == null ? other.doc == null : doc.equals(other.doc)) && metadata.equals(other.metadata); } }
DocumentSnapshot { @Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof DocumentSnapshot)) { return false; } DocumentSnapshot other = (DocumentSnapshot) obj; return firestore.equals(other.firestore) && key.equals(other.key) && (doc == null ? other.doc == null : doc.equals(other.doc)) && metadata.equals(other.metadata); } DocumentSnapshot(
      FirebaseFirestore firestore,
      DocumentKey key,
      @Nullable Document doc,
      boolean isFromCache,
      boolean hasPendingWrites); }
DocumentSnapshot { @Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof DocumentSnapshot)) { return false; } DocumentSnapshot other = (DocumentSnapshot) obj; return firestore.equals(other.firestore) && key.equals(other.key) && (doc == null ? other.doc == null : doc.equals(other.doc)) && metadata.equals(other.metadata); } DocumentSnapshot(
      FirebaseFirestore firestore,
      DocumentKey key,
      @Nullable Document doc,
      boolean isFromCache,
      boolean hasPendingWrites); @NonNull String getId(); @NonNull SnapshotMetadata getMetadata(); boolean exists(); @Nullable Map<String, Object> getData(); @Nullable Map<String, Object> getData(@NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable T toObject(@NonNull Class<T> valueType); @Nullable T toObject(
      @NonNull Class<T> valueType, @NonNull ServerTimestampBehavior serverTimestampBehavior); boolean contains(@NonNull String field); boolean contains(@NonNull FieldPath fieldPath); @Nullable Object get(@NonNull String field); @Nullable Object get(
      @NonNull String field, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Object get(@NonNull FieldPath fieldPath); @Nullable Object get(
      @NonNull FieldPath fieldPath, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable T get(@NonNull String field, @NonNull Class<T> valueType); @Nullable T get(
      @NonNull String field,
      @NonNull Class<T> valueType,
      @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable T get(@NonNull FieldPath fieldPath, @NonNull Class<T> valueType); @Nullable T get(
      @NonNull FieldPath fieldPath,
      @NonNull Class<T> valueType,
      @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Boolean getBoolean(@NonNull String field); @Nullable Double getDouble(@NonNull String field); @Nullable String getString(@NonNull String field); @Nullable Long getLong(@NonNull String field); @Nullable Date getDate(@NonNull String field); @Nullable Date getDate(
      @NonNull String field, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Timestamp getTimestamp(@NonNull String field); @Nullable Timestamp getTimestamp(
      @NonNull String field, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Blob getBlob(@NonNull String field); @Nullable GeoPoint getGeoPoint(@NonNull String field); @Nullable DocumentReference getDocumentReference(@NonNull String field); @NonNull DocumentReference getReference(); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); @Override String toString(); }
DocumentSnapshot { @Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof DocumentSnapshot)) { return false; } DocumentSnapshot other = (DocumentSnapshot) obj; return firestore.equals(other.firestore) && key.equals(other.key) && (doc == null ? other.doc == null : doc.equals(other.doc)) && metadata.equals(other.metadata); } DocumentSnapshot(
      FirebaseFirestore firestore,
      DocumentKey key,
      @Nullable Document doc,
      boolean isFromCache,
      boolean hasPendingWrites); @NonNull String getId(); @NonNull SnapshotMetadata getMetadata(); boolean exists(); @Nullable Map<String, Object> getData(); @Nullable Map<String, Object> getData(@NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable T toObject(@NonNull Class<T> valueType); @Nullable T toObject(
      @NonNull Class<T> valueType, @NonNull ServerTimestampBehavior serverTimestampBehavior); boolean contains(@NonNull String field); boolean contains(@NonNull FieldPath fieldPath); @Nullable Object get(@NonNull String field); @Nullable Object get(
      @NonNull String field, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Object get(@NonNull FieldPath fieldPath); @Nullable Object get(
      @NonNull FieldPath fieldPath, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable T get(@NonNull String field, @NonNull Class<T> valueType); @Nullable T get(
      @NonNull String field,
      @NonNull Class<T> valueType,
      @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable T get(@NonNull FieldPath fieldPath, @NonNull Class<T> valueType); @Nullable T get(
      @NonNull FieldPath fieldPath,
      @NonNull Class<T> valueType,
      @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Boolean getBoolean(@NonNull String field); @Nullable Double getDouble(@NonNull String field); @Nullable String getString(@NonNull String field); @Nullable Long getLong(@NonNull String field); @Nullable Date getDate(@NonNull String field); @Nullable Date getDate(
      @NonNull String field, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Timestamp getTimestamp(@NonNull String field); @Nullable Timestamp getTimestamp(
      @NonNull String field, @NonNull ServerTimestampBehavior serverTimestampBehavior); @Nullable Blob getBlob(@NonNull String field); @Nullable GeoPoint getGeoPoint(@NonNull String field); @Nullable DocumentReference getDocumentReference(@NonNull String field); @NonNull DocumentReference getReference(); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); @Override String toString();  }