Class DocumentSnapshot

java.lang.Object
com.codename1.cloud.firebase.DocumentSnapshot

public final class DocumentSnapshot extends Object
An immutable copy of one Firestore document as the server returned it.
  • Constructor Details

    • DocumentSnapshot

      public DocumentSnapshot(String name, Map<String,Object> data, String createTime, String updateTime)

      Creates a snapshot.

      Parameters
      • name: the full resource name

      • data: the decoded fields, or null when the document does not exist

      • createTime: the server create time, may be null

      • updateTime: the server update time, may be null

  • Method Details

    • fromJson

      public static DocumentSnapshot fromJson(Map doc)

      Builds a snapshot from a REST Document object.

      Parameters
      • doc: the parsed JSON document
      Returns

      the snapshot

    • exists

      public boolean exists()
      Returns

      true when the document exists

    • getName

      public String getName()
      Returns

      the full resource name

    • getId

      public String getId()
      Returns

      the last path segment, the document ID

    • getPath

      public String getPath()
      Returns

      the path relative to the database root, such as cities/SF

    • getData

      public Map<String,Object> getData()
      Returns

      the decoded fields, or null when the document does not exist

    • get

      public Object get(String field)

      Reads one top-level field.

      Parameters
      • field: the field name
      Returns

      the value, or null

    • getUpdateTime

      public String getUpdateTime()
      Returns

      the RFC 3339 update time, or null

    • getCreateTime

      public String getCreateTime()
      Returns

      the RFC 3339 create time, or null

    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object