# Google Cloud Optimization V1 Client - Class FieldReference (1.1.3)

1.1.3 (latest) 1.1.2 1.0.5 0.7.0 0.6.5 0.5.1 0.4.0 0.3.4 0.2.0 0.1.9 Reference documentation and code samples for the Google Cloud Optimization V1 Client class FieldReference.

Specifies a context for the validation error. A `FieldReference` always
refers to a given field in this file and follows the same hierarchical
structure. For example, we may specify element #2 of `start_time_windows`
of vehicle #5 using:

    name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }

We however omit top-level entities such as `OptimizeToursRequest` or
`ShipmentModel` to avoid crowding the message.

Generated from protobuf message `google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference`

## Namespace

Google \\ Cloud \\ Optimization \\ V1 \\ OptimizeToursValidationError

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Name of the field, e.g., "vehicles". |
| `↳ index` | `int` Index of the field if repeated. |
| `↳ key` | `string` Key if the field is a map. |
| `↳ sub_field` | `https://docs.cloud.google.com/php/docs/reference/cloud-optimization/latest/V1.OptimizeToursValidationError.FieldReference` Recursively nested sub-field, if needed. |

### getName

Name of the field, e.g., "vehicles".

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Name of the field, e.g., "vehicles".

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getIndex

Index of the field if repeated.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasIndex

### setIndex

Index of the field if repeated.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getKey

Key if the field is a map.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasKey

### setKey

Key if the field is a map.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSubField

Recursively nested sub-field, if needed.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-optimization/latest/V1.OptimizeToursValidationError.FieldReference|null` |   |

### hasSubField

### clearSubField

### setSubField

Recursively nested sub-field, if needed.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-optimization/latest/V1.OptimizeToursValidationError.FieldReference` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getIndexOrKey

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |