# Class FieldValue (2.65.0)

2.65.0 (latest) 2.62.0 2.61.0 2.60.0 2.59.0 2.58.0 2.57.2 2.56.0 2.55.3 2.54.2 2.53.0 2.52.0 2.51.0 2.50.1 2.49.0 2.48.1 2.47.0 2.46.0 2.45.0 2.44.0 2.43.3 2.42.3 2.41.0 2.40.3 2.39.1 2.38.2 2.37.2 2.36.0 2.35.0 2.34.2 2.33.2

    public class FieldValue implements Serializable

Google BigQuery Table Field Value class. Objects of this class represent values of a BigQuery
Table Field. A list of values forms a table row. Tables rows can be gotten as the result of a
query or when listing table data.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> FieldValue

## Implements

[Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### of(FieldValue.Attribute attribute, Object value)

    public static FieldValue of(FieldValue.Attribute attribute, Object value)

> [!WARNING]
> **Beta**
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Creates an instance of `FieldValue`, useful for testing.

If the `attribute` is Attribute#PRIMITIVE, the `value` should be the
string representation of the underlying value, eg `"123"` for number `123`.

If the `attribute` is Attribute#REPEATED or Attribute#RECORD, the
`value` should be `List` of [FieldValue](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue)s or [FieldValueList](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValueList),
respectively.

This method is unstable. See [this discussion](https://github.com/googleapis/google-cloud-java/pull/2891) for more
context.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `attribute` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue.Attribute` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue` |   |

### of(FieldValue.Attribute attribute, Object value, Boolean useInt64Timestamps)

    public static FieldValue of(FieldValue.Attribute attribute, Object value, Boolean useInt64Timestamps)

> [!WARNING]
> **Beta**
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `attribute` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue.Attribute` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |
| `useInt64Timestamps` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue` |   |

## Methods

### equals(Object obj)

    public final boolean equals(Object obj)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `obj` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)

### getAttribute()

    public FieldValue.Attribute getAttribute()

Returns the attribute of this Field Value.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue.Attribute` | Attribute#PRIMITIVE if the field is a primitive type ([LegacySQLTypeName#BYTES](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_BYTES), [LegacySQLTypeName#BOOLEAN](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_BOOLEAN), [LegacySQLTypeName#STRING](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_STRING), [LegacySQLTypeName#FLOAT](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_FLOAT), [LegacySQLTypeName#INTEGER](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_INTEGER), [LegacySQLTypeName#NUMERIC](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_NUMERIC), [LegacySQLTypeName#TIMESTAMP](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_TIMESTAMP), [LegacySQLTypeName#GEOGRAPHY](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_GEOGRAPHY)) or is `null`. Returns Attribute#REPEATED if the corresponding field has ([Field.Mode#REPEATED](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.Field.Mode#com_google_cloud_bigquery_Field_Mode_REPEATED)) mode. Returns Attribute#RECORD if the corresponding field is a [LegacySQLTypeName#RECORD](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_RECORD) type. |

### getBooleanValue()

    public boolean getBooleanValue()

Returns this field's value as a [Boolean](https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html). This method should only be used if the
corresponding field has [LegacySQLTypeName#BOOLEAN](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_BOOLEAN) type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getBytesValue()

    public byte[] getBytesValue()

Returns this field's value as a byte array. This method should only be used if the
corresponding field has primitive type ([LegacySQLTypeName#BYTES](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_BYTES).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[]` |   |

### getDoubleValue()

    public double getDoubleValue()

Returns this field's value as a Double. This method should only be used if the
corresponding field has [LegacySQLTypeName#FLOAT](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_FLOAT) type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getLongValue()

    public long getLongValue()

Returns this field's value as a `long`. This method should only be used if the
corresponding field has [LegacySQLTypeName#INTEGER](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_INTEGER) type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getNumericValue()

    public BigDecimal getNumericValue()

Returns this field's value as a [java.math.BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). This method should only be used
if the corresponding field has [LegacySQLTypeName#NUMERIC](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_NUMERIC) type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html` |   |

### getPeriodDuration()

    public PeriodDuration getPeriodDuration()

Returns this field's value as a org.threeten.extra.PeriodDuration. This method should
be used if the corresponding field has [StandardSQLTypeName#INTERVAL](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.StandardSQLTypeName#com_google_cloud_bigquery_StandardSQLTypeName_INTERVAL) type, or if it is a
legal canonical format "\[sign\]Y-M \[sign\]D \[sign\]H:M:S\[.F\]", e.g. "123-7 -19 0:24:12.000006" or
ISO 8601.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.threeten.extra.PeriodDuration` |   |

### getRangeValue()

    public Range getRangeValue()

Returns this field's value as a [Range](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.Range). This method should only be used \* if the
corresponding field has [LegacySQLTypeName#RANGE](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_RANGE) type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.Range` |   |

### getRecordValue()

    public FieldValueList getRecordValue()

Returns this field's value as a [FieldValueList](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValueList) instance. This method should only be
used if the corresponding field has [LegacySQLTypeName#RECORD](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_RECORD) type (i.e. [#getAttribute()](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue#com_google_cloud_bigquery_FieldValue_getAttribute__) is Attribute#RECORD).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValueList` |   |

### getRepeatedValue()

    public List<FieldValue> getRepeatedValue()

Returns this field's value as a list of [FieldValue](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue). This method should only be used if
the corresponding field has [Field.Mode#REPEATED](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.Field.Mode#com_google_cloud_bigquery_Field_Mode_REPEATED) mode (i.e. [#getAttribute()](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue#com_google_cloud_bigquery_FieldValue_getAttribute__) is
Attribute#REPEATED).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue>` |   |

### getStringValue()

    public String getStringValue()

Returns this field's value as a [String](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html). This method should only be used if the
corresponding field has primitive type ([LegacySQLTypeName#BYTES](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_BYTES), [LegacySQLTypeName#BOOLEAN](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_BOOLEAN), [LegacySQLTypeName#STRING](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_STRING), [LegacySQLTypeName#FLOAT](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_FLOAT),
[LegacySQLTypeName#INTEGER](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_INTEGER), [LegacySQLTypeName#NUMERIC](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_NUMERIC) [LegacySQLTypeName#TIMESTAMP](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_TIMESTAMP)).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getStringValueOrDefault(String defaultValue)

    public String getStringValueOrDefault(String defaultValue)

Returns this field's value as a [String](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html), or defaultValue if [#isNull()](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue#com_google_cloud_bigquery_FieldValue_isNull__) returns
`true`. See [#getStringValue()](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue#com_google_cloud_bigquery_FieldValue_getStringValue__) for more details.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `defaultValue` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getTimestampInstant()

    public Instant getTimestampInstant()

Returns this field's value as a `String`, representing a timestamp as an Instant. This
method should only be used if the corresponding field has [LegacySQLTypeName#TIMESTAMP](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_TIMESTAMP)
type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html` |   |

### getTimestampValue()

    public long getTimestampValue()

Returns this field's value as a `long`, representing a timestamp in microseconds since
epoch (UNIX time). This method should only be used if the corresponding field has [LegacySQLTypeName#TIMESTAMP](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.LegacySQLTypeName#com_google_cloud_bigquery_LegacySQLTypeName_TIMESTAMP) type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getUseInt64Timestamps()

    public Boolean getUseInt64Timestamps()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html` |   |

### getValue()

    public Object getValue()

Returns this field's value as an [Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html). If [#isNull()](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigquery/latest/com.google.cloud.bigquery.FieldValue#com_google_cloud_bigquery_FieldValue_isNull__) is `true` this
method returns `null`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |   |

### hashCode()

    public final int hashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)

### isNull()

    public boolean isNull()

Returns `true` if this field's value is `null`, `false` otherwise.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### toString()

    public String toString()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)