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

namespace Google\Cloud\Spanner\V1;

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

/**
 * `Type` indicates the type of a Cloud Spanner value, as might be stored in a
 * table cell or returned from an SQL query.
 *
 * Generated from protobuf message <code>google.spanner.v1.Type</code>
 */
class Type extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
     *
     * Generated from protobuf field <code>.google.spanner.v1.TypeCode code = 1;</code>
     */
    private $code = 0;
    /**
     * If [code][google.spanner.v1.Type.code] ==
     * [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
     * type of the array elements.
     *
     * Generated from protobuf field <code>.google.spanner.v1.Type array_element_type = 2;</code>
     */
    private $array_element_type = null;
    /**
     * If [code][google.spanner.v1.Type.code] ==
     * [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
     * type information for the struct's fields.
     *
     * Generated from protobuf field <code>.google.spanner.v1.StructType struct_type = 3;</code>
     */
    private $struct_type = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type int $code
     *           Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
     *     @type \Google\Cloud\Spanner\V1\Type $array_element_type
     *           If [code][google.spanner.v1.Type.code] ==
     *           [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
     *           type of the array elements.
     *     @type \Google\Cloud\Spanner\V1\StructType $struct_type
     *           If [code][google.spanner.v1.Type.code] ==
     *           [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
     *           type information for the struct's fields.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Spanner\V1\Type::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
     *
     * Generated from protobuf field <code>.google.spanner.v1.TypeCode code = 1;</code>
     * @return int
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
     *
     * Generated from protobuf field <code>.google.spanner.v1.TypeCode code = 1;</code>
     * @param int $var
     * @return $this
     */
    public function setCode($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\TypeCode::class);
        $this->code = $var;

        return $this;
    }

    /**
     * If [code][google.spanner.v1.Type.code] ==
     * [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
     * type of the array elements.
     *
     * Generated from protobuf field <code>.google.spanner.v1.Type array_element_type = 2;</code>
     * @return \Google\Cloud\Spanner\V1\Type
     */
    public function getArrayElementType()
    {
        return $this->array_element_type;
    }

    /**
     * If [code][google.spanner.v1.Type.code] ==
     * [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
     * type of the array elements.
     *
     * Generated from protobuf field <code>.google.spanner.v1.Type array_element_type = 2;</code>
     * @param \Google\Cloud\Spanner\V1\Type $var
     * @return $this
     */
    public function setArrayElementType($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Type::class);
        $this->array_element_type = $var;

        return $this;
    }

    /**
     * If [code][google.spanner.v1.Type.code] ==
     * [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
     * type information for the struct's fields.
     *
     * Generated from protobuf field <code>.google.spanner.v1.StructType struct_type = 3;</code>
     * @return \Google\Cloud\Spanner\V1\StructType
     */
    public function getStructType()
    {
        return $this->struct_type;
    }

    /**
     * If [code][google.spanner.v1.Type.code] ==
     * [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
     * type information for the struct's fields.
     *
     * Generated from protobuf field <code>.google.spanner.v1.StructType struct_type = 3;</code>
     * @param \Google\Cloud\Spanner\V1\StructType $var
     * @return $this
     */
    public function setStructType($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\StructType::class);
        $this->struct_type = $var;

        return $this;
    }

}

