<?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 [(.google.api.field_behavior) = REQUIRED];</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;
    /**
     * The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that disambiguates SQL type that Spanner will
     * use to represent values of this type during query processing. This is
     * necessary for some type codes because a single [TypeCode][google.spanner.v1.TypeCode] can be mapped
     * to different SQL types depending on the SQL dialect. [type_annotation][google.spanner.v1.Type.type_annotation]
     * typically is not needed to process the content of a value (it doesn't
     * affect serialization) and clients can ignore it on the read path.
     *
     * Generated from protobuf field <code>.google.spanner.v1.TypeAnnotationCode type_annotation = 4;</code>
     */
    private $type_annotation = 0;

    /**
     * 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.
     *     @type int $type_annotation
     *           The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that disambiguates SQL type that Spanner will
     *           use to represent values of this type during query processing. This is
     *           necessary for some type codes because a single [TypeCode][google.spanner.v1.TypeCode] can be mapped
     *           to different SQL types depending on the SQL dialect. [type_annotation][google.spanner.v1.Type.type_annotation]
     *           typically is not needed to process the content of a value (it doesn't
     *           affect serialization) and clients can ignore it on the read path.
     * }
     */
    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 [(.google.api.field_behavior) = REQUIRED];</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 [(.google.api.field_behavior) = REQUIRED];</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|null
     */
    public function getArrayElementType()
    {
        return $this->array_element_type;
    }

    public function hasArrayElementType()
    {
        return isset($this->array_element_type);
    }

    public function clearArrayElementType()
    {
        unset($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|null
     */
    public function getStructType()
    {
        return $this->struct_type;
    }

    public function hasStructType()
    {
        return isset($this->struct_type);
    }

    public function clearStructType()
    {
        unset($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;
    }

    /**
     * The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that disambiguates SQL type that Spanner will
     * use to represent values of this type during query processing. This is
     * necessary for some type codes because a single [TypeCode][google.spanner.v1.TypeCode] can be mapped
     * to different SQL types depending on the SQL dialect. [type_annotation][google.spanner.v1.Type.type_annotation]
     * typically is not needed to process the content of a value (it doesn't
     * affect serialization) and clients can ignore it on the read path.
     *
     * Generated from protobuf field <code>.google.spanner.v1.TypeAnnotationCode type_annotation = 4;</code>
     * @return int
     */
    public function getTypeAnnotation()
    {
        return $this->type_annotation;
    }

    /**
     * The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that disambiguates SQL type that Spanner will
     * use to represent values of this type during query processing. This is
     * necessary for some type codes because a single [TypeCode][google.spanner.v1.TypeCode] can be mapped
     * to different SQL types depending on the SQL dialect. [type_annotation][google.spanner.v1.Type.type_annotation]
     * typically is not needed to process the content of a value (it doesn't
     * affect serialization) and clients can ignore it on the read path.
     *
     * Generated from protobuf field <code>.google.spanner.v1.TypeAnnotationCode type_annotation = 4;</code>
     * @param int $var
     * @return $this
     */
    public function setTypeAnnotation($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\TypeAnnotationCode::class);
        $this->type_annotation = $var;

        return $this;
    }

}

