<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/optimization/v1/fleet_routing.proto

namespace Google\Cloud\Optimization\V1\OptimizeToursValidationError;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * 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 <code>google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference</code>
 */
class FieldReference extends \Google\Protobuf\Internal\Message
{
    /**
     * Name of the field, e.g., "vehicles".
     *
     * Generated from protobuf field <code>string name = 1;</code>
     */
    private $name = '';
    /**
     * Recursively nested sub-field, if needed.
     *
     * Generated from protobuf field <code>.google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference sub_field = 3;</code>
     */
    private $sub_field = null;
    protected $index_or_key;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $name
     *           Name of the field, e.g., "vehicles".
     *     @type int $index
     *           Index of the field if repeated.
     *     @type string $key
     *           Key if the field is a map.
     *     @type \Google\Cloud\Optimization\V1\OptimizeToursValidationError\FieldReference $sub_field
     *           Recursively nested sub-field, if needed.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Optimization\V1\FleetRouting::initOnce();
        parent::__construct($data);
    }

    /**
     * Name of the field, e.g., "vehicles".
     *
     * Generated from protobuf field <code>string name = 1;</code>
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Name of the field, e.g., "vehicles".
     *
     * Generated from protobuf field <code>string name = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setName($var)
    {
        GPBUtil::checkString($var, True);
        $this->name = $var;

        return $this;
    }

    /**
     * Index of the field if repeated.
     *
     * Generated from protobuf field <code>int32 index = 2;</code>
     * @return int
     */
    public function getIndex()
    {
        return $this->readOneof(2);
    }

    public function hasIndex()
    {
        return $this->hasOneof(2);
    }

    /**
     * Index of the field if repeated.
     *
     * Generated from protobuf field <code>int32 index = 2;</code>
     * @param int $var
     * @return $this
     */
    public function setIndex($var)
    {
        GPBUtil::checkInt32($var);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * Key if the field is a map.
     *
     * Generated from protobuf field <code>string key = 4;</code>
     * @return string
     */
    public function getKey()
    {
        return $this->readOneof(4);
    }

    public function hasKey()
    {
        return $this->hasOneof(4);
    }

    /**
     * Key if the field is a map.
     *
     * Generated from protobuf field <code>string key = 4;</code>
     * @param string $var
     * @return $this
     */
    public function setKey($var)
    {
        GPBUtil::checkString($var, True);
        $this->writeOneof(4, $var);

        return $this;
    }

    /**
     * Recursively nested sub-field, if needed.
     *
     * Generated from protobuf field <code>.google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference sub_field = 3;</code>
     * @return \Google\Cloud\Optimization\V1\OptimizeToursValidationError\FieldReference|null
     */
    public function getSubField()
    {
        return $this->sub_field;
    }

    public function hasSubField()
    {
        return isset($this->sub_field);
    }

    public function clearSubField()
    {
        unset($this->sub_field);
    }

    /**
     * Recursively nested sub-field, if needed.
     *
     * Generated from protobuf field <code>.google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference sub_field = 3;</code>
     * @param \Google\Cloud\Optimization\V1\OptimizeToursValidationError\FieldReference $var
     * @return $this
     */
    public function setSubField($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Optimization\V1\OptimizeToursValidationError\FieldReference::class);
        $this->sub_field = $var;

        return $this;
    }

    /**
     * @return string
     */
    public function getIndexOrKey()
    {
        return $this->whichOneof("index_or_key");
    }

}


