FieldValue

public abstract classFieldValue


Sentinel values that can be used when writing document fields withset() orupdate().

Summary

Public methods

static @NonNullFieldValue
arrayRemove(Object[] elements)

Returns a special value that can be used withset() orupdate() that tells the server to remove the given elements from any array value that already exists on the server.

static @NonNullFieldValue
arrayUnion(Object[] elements)

Returns a special value that can be used withset() orupdate() that tells the server to union the given elements with any array value that already exists on the server.

static @NonNullFieldValue

Returns a sentinel for use withupdate() to mark a field for deletion.

static @NonNullFieldValue
increment(long l)

Returns a special value that can be used withset() orupdate() that tells the server to increment the field's current value by the given value.

static @NonNullFieldValue
increment(double l)

Returns a special value that can be used withset() orupdate() that tells the server to increment the field's current value by the given value.

static @NonNullFieldValue

Returns a sentinel for use withset() orupdate() to include a server-generated timestamp in the written data.

static @NonNullVectorValue
vector(@NonNull double[] values)

Creates a newVectorValue constructed with a copy of the given array of doubles.

Public methods

arrayRemove

public static @NonNullFieldValue arrayRemove(Object[] elements)

Returns a special value that can be used withset() orupdate() that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array.

Parameters
Object[] elements

The elements to remove from the array.

Returns
@NonNullFieldValue

TheFieldValue sentinel for use in a call toset() orupdate().

arrayUnion

public static @NonNullFieldValue arrayUnion(Object[] elements)

Returns a special value that can be used withset() orupdate() that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements.

Parameters
Object[] elements

The elements to union into the array.

Returns
@NonNullFieldValue

TheFieldValue sentinel for use in a call toset() orupdate().

delete

public static @NonNullFieldValue delete()

Returns a sentinel for use withupdate() to mark a field for deletion.

increment

public static @NonNullFieldValue increment(long l)

Returns a special value that can be used withset() orupdate() that tells the server to increment the field's current value by the given value.

If the current field value is an integer, possible integer overflows are resolved to Long.MAX_VALUE or Long.MIN_VALUE. If the current field value is a double, both values will be interpreted as doubles and the arithmetic will follow IEEE 754 semantics.

If the current field is not an integer or double, or if the field does not yet exist, the transformation will set the field to the given value.

Returns
@NonNullFieldValue

TheFieldValue sentinel for use in a call toset() orupdate().

increment

public static @NonNullFieldValue increment(double l)

Returns a special value that can be used withset() orupdate() that tells the server to increment the field's current value by the given value.

If the current value is an integer or a double, both the current and the given value will be interpreted as doubles and all arithmetic will follow IEEE 754 semantics. Otherwise, the transformation will set the field to the given value.

Returns
@NonNullFieldValue

TheFieldValue sentinel for use in a call toset() orupdate().

serverTimestamp

public static @NonNullFieldValue serverTimestamp()

Returns a sentinel for use withset() orupdate() to include a server-generated timestamp in the written data.

vector

public static @NonNullVectorValue vector(@NonNull double[] values)

Creates a newVectorValue constructed with a copy of the given array of doubles.

Parameters
@NonNull double[] values

Array of doubles to be copied to create aVectorValue.

Returns
@NonNullVectorValue

A newVectorValue constructed with a copy of the given array of doubles.

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.