Class SetOptions (3.4.2)

public final class SetOptions

An options object that configures the behavior of set() calls. By providing one of the SetOptions objects returned by #merge, #mergeFields and #mergeFieldPaths, the set() calls in DocumentReference, WriteBatch and Transaction can be configured to perform granular merges instead of overwriting the target documents in their entirety.

Inheritance

Object > SetOptions

Static Methods

merge()

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.

Returns
TypeDescription
SetOptions

mergeFieldPaths(List<FieldPath> fields)

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.

Parameter
NameDescription
fieldsList<FieldPath>

The list of fields to merge.

Returns
TypeDescription
SetOptions

mergeFields(String[] fields)

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.

Parameter
NameDescription
fieldsString[]

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

Returns
TypeDescription
SetOptions

mergeFields(List<String> fields)

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.

Parameter
NameDescription
fieldsList<String>

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

Returns
TypeDescription
SetOptions

Methods

equals(Object obj)

public boolean equals(Object obj)

Returns true if this SetOptions is equal to the provided object.

Parameter
NameDescription
objObject

The object to compare against.

Returns
TypeDescription
boolean

Whether this SetOptions is equal to the provided object.

Overrides

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides