Class SetOptions

java.lang.Object
com.google.cloud.firestore.SetOptions

public final class SetOptions extends Object
An options object that configures the behavior of set() calls. By providing one of the SetOptions objects returned by merge, mergeFields(java.util.List<java.lang.String>) and mergeFieldPaths(java.util.List<com.google.cloud.firestore.FieldPath>), the set() calls in DocumentReference, WriteBatch and Transaction can be configured to perform granular merges instead of overwriting the target documents in their entirety.
  • Method Details

    • merge

      @Nonnull public static SetOptions merge()
      Changes the behavior of set() calls to only replace the values specified in its data argument. Fields with no corresponding values in the data passed to set() will remain untouched.
    • mergeFields

      @Nonnull public static SetOptions mergeFields(List<String> fields)
      Changes the behavior of set() calls to only replace the fields under fieldPaths. Any field that is not specified in fieldPaths is ignored and remains untouched.

      It is an error to pass a SetOptions object to a set() call that is missing a value for any of the fields specified here.

      Parameters:
      fields - The list of fields to merge. Fields can contain dots to reference nested fields within the document.
    • mergeFields

      @Nonnull public static SetOptions mergeFields(String... fields)
      Changes the behavior of set() calls to only replace the fields under fieldPaths. Any field that is not specified in fieldPaths is ignored and remains untouched.

      It is an error to pass a SetOptions object to a set() call that is missing a value for any of the fields specified here.

      Parameters:
      fields - The list of fields to merge. Fields can contain dots to reference nested fields within the document.
    • mergeFieldPaths

      @Nonnull public static SetOptions mergeFieldPaths(List<FieldPath> fields)
      Changes the behavior of set() calls to only replace the fields under fieldPaths. Any field that is not specified in fieldPaths is ignored and remains untouched.

      It is an error to pass a SetOptions object to a set() call that is missing a value for any of the fields specified here in its to data argument.

      Parameters:
      fields - The list of fields to merge.
    • equals

      public boolean equals(Object obj)
      Returns true if this SetOptions is equal to the provided object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare against.
      Returns:
      Whether this SetOptions is equal to the provided object.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object