<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/shopping/type/types.proto

namespace Google\Shopping\Type;

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

/**
 * A message that represents custom attributes. Exactly one of `value` or
 * `group_values` must not be empty.
 *
 * Generated from protobuf message <code>google.shopping.type.CustomAttribute</code>
 */
class CustomAttribute extends \Google\Protobuf\Internal\Message
{
    /**
     * The name of the attribute.
     *
     * Generated from protobuf field <code>optional string name = 1;</code>
     */
    protected $name = null;
    /**
     * The value of the attribute. If `value` is not empty, `group_values` must be
     * empty.
     *
     * Generated from protobuf field <code>optional string value = 2;</code>
     */
    protected $value = null;
    /**
     * Subattributes within this attribute group.  If
     * `group_values` is not empty, `value` must be empty.
     *
     * Generated from protobuf field <code>repeated .google.shopping.type.CustomAttribute group_values = 3;</code>
     */
    private $group_values;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $name
     *           The name of the attribute.
     *     @type string $value
     *           The value of the attribute. If `value` is not empty, `group_values` must be
     *           empty.
     *     @type array<\Google\Shopping\Type\CustomAttribute>|\Google\Protobuf\Internal\RepeatedField $group_values
     *           Subattributes within this attribute group.  If
     *           `group_values` is not empty, `value` must be empty.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Shopping\Type\Types::initOnce();
        parent::__construct($data);
    }

    /**
     * The name of the attribute.
     *
     * Generated from protobuf field <code>optional string name = 1;</code>
     * @return string
     */
    public function getName()
    {
        return isset($this->name) ? $this->name : '';
    }

    public function hasName()
    {
        return isset($this->name);
    }

    public function clearName()
    {
        unset($this->name);
    }

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

        return $this;
    }

    /**
     * The value of the attribute. If `value` is not empty, `group_values` must be
     * empty.
     *
     * Generated from protobuf field <code>optional string value = 2;</code>
     * @return string
     */
    public function getValue()
    {
        return isset($this->value) ? $this->value : '';
    }

    public function hasValue()
    {
        return isset($this->value);
    }

    public function clearValue()
    {
        unset($this->value);
    }

    /**
     * The value of the attribute. If `value` is not empty, `group_values` must be
     * empty.
     *
     * Generated from protobuf field <code>optional string value = 2;</code>
     * @param string $var
     * @return $this
     */
    public function setValue($var)
    {
        GPBUtil::checkString($var, True);
        $this->value = $var;

        return $this;
    }

    /**
     * Subattributes within this attribute group.  If
     * `group_values` is not empty, `value` must be empty.
     *
     * Generated from protobuf field <code>repeated .google.shopping.type.CustomAttribute group_values = 3;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getGroupValues()
    {
        return $this->group_values;
    }

    /**
     * Subattributes within this attribute group.  If
     * `group_values` is not empty, `value` must be empty.
     *
     * Generated from protobuf field <code>repeated .google.shopping.type.CustomAttribute group_values = 3;</code>
     * @param array<\Google\Shopping\Type\CustomAttribute>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setGroupValues($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Shopping\Type\CustomAttribute::class);
        $this->group_values = $arr;

        return $this;
    }

}

