title: Firestore - Why check if DocumentSnapshot is not null AND call exists?
body: <p>Take a look at this code example from the <code>Firestore</code> documentation:</p>
  
  <pre><code>DocumentReference docRef = db.collection("cities").document("SF");
  docRef.get().addOnCompleteListener(new OnCompleteListener&lt;DocumentSnapshot&gt;() {
      @Override
      public void onComplete(@NonNull Task&lt;DocumentSnapshot&gt; task) {
          if (task.isSuccessful()) {
              DocumentSnapshot document = task.getResult();
              if (document != null &amp;&amp; document.exists()) {
                  Log.d(TAG, "DocumentSnapshot data: " + document.getData());
              } else {
                  Log.d(TAG, "No such document");
              }
          } else {
             Log.d(TAG, "get failed with ", task.getException());
          }
      }
  });
  </code></pre>
  
  <p><a href="https://firebase.google.com/docs/firestore/query-data/get-data" rel="noreferrer">https://firebase.google.com/docs/firestore/query-data/get-data</a></p>
  
  <p>Why check if <code>document != null</code>? If I read the source code correctly (beginner), the <code>exists</code> method checks for nullity internally.</p>