Class SetOptions (3.22.0)

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
Type Description
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
Name Description
fields List<FieldPath>

The list of fields to merge.

Returns
Type Description
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
Name Description
fields String[]

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

Returns
Type Description
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
Name Description
fields List<String>

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

Returns
Type Description
SetOptions

Methods

equals(Object obj)

public boolean equals(Object obj)

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

Parameter
Name Description
obj Object

The object to compare against.

Returns
Type Description
boolean

Whether this SetOptions is equal to the provided object.

Overrides

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides