SetOptions

public final classSetOptions


An options object that configures the behavior ofset() calls. By providing one of the SetOptions objects returned bymerge,mergeFields andmergeFieldPaths, theset() calls inDocumentReference,WriteBatch andTransaction can be configured to perform granular merges instead of overwriting the target documents in their entirety.

Summary

Public fields

final @NullableFieldMask

Public methods

boolean
int
static @NonNullSetOptions

Changes the behavior ofset() calls to only replace the values specified in its data argument.

static @NonNullSetOptions

Changes the behavior ofset() calls to only replace the given fields.

static @NonNullSetOptions
mergeFields(String[] fields)

Changes the behavior ofset() calls to only replace the given fields.

static @NonNullSetOptions

Changes the behavior ofset() calls to only replace the given fields.

Public fields

fieldMask

public final @NullableFieldMask fieldMask

Public methods

equals

public boolean equals(Object o)

hashCode

public int hashCode()

merge

public static @NonNullSetOptions merge()

Changes the behavior ofset() calls to only replace the values specified in its data argument. Fields omitted from theset() call will remain untouched. If your input sets any field to an empty map, all nested fields are overwritten.

mergeFieldPaths

public static @NonNullSetOptions mergeFieldPaths(@NonNullList<FieldPath> fields)

Changes the behavior ofset() calls to only replace the given fields. Any field that is not specified infields is ignored and remains untouched.

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

Parameters
@NonNullList<FieldPath> fields

The list of fields to merge.

mergeFields

public static @NonNullSetOptions mergeFields(String[] fields)

Changes the behavior ofset() calls to only replace the given fields. Any field that is not specified infields is ignored and remains untouched.

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

Parameters
String[] fields

The list of fields to merge. Fields can contain dots to reference nested fields within the document.

mergeFields

public static @NonNullSetOptions mergeFields(@NonNullList<String> fields)

Changes the behavior ofset() calls to only replace the given fields. Any field that is not specified infields is ignored and remains untouched. If your input sets any field to an empty map, all nested fields are overwritten.

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

Parameters
@NonNullList<String> fields

The list of fields to merge. Fields can contain dots to reference nested fields within the document.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.