<?php
/**
 * Autogenerated by Thrift Compiler (0.12.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;

/**
 * 意图槽位
 */
class IntentSlot
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'intent_id',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        2 => array(
            'var' => 'name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        3 => array(
            'var' => 'dict_id',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        4 => array(
            'var' => 'requires',
            'isRequired' => false,
            'type' => TType::BOOL,
        ),
        5 => array(
            'var' => 'id',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        6 => array(
            'var' => 'createdate',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        7 => array(
            'var' => 'updatedate',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        8 => array(
            'var' => 'question',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        9 => array(
            'var' => 'dict',
            'isRequired' => false,
            'type' => TType::STRUCT,
            'class' => '\Dict',
        ),
    );

    /**
     * @var string
     */
    public $intent_id = null;
    /**
     * @var string
     */
    public $name = null;
    /**
     * @var string
     */
    public $dict_id = null;
    /**
     * @var bool
     */
    public $requires = null;
    /**
     * @var string
     */
    public $id = null;
    /**
     * @var string
     */
    public $createdate = null;
    /**
     * @var string
     */
    public $updatedate = null;
    /**
     * @var string
     */
    public $question = null;
    /**
     * @var \Dict
     */
    public $dict = null;

    public function __construct($vals = null)
    {
        if (is_array($vals)) {
            if (isset($vals['intent_id'])) {
                $this->intent_id = $vals['intent_id'];
            }
            if (isset($vals['name'])) {
                $this->name = $vals['name'];
            }
            if (isset($vals['dict_id'])) {
                $this->dict_id = $vals['dict_id'];
            }
            if (isset($vals['requires'])) {
                $this->requires = $vals['requires'];
            }
            if (isset($vals['id'])) {
                $this->id = $vals['id'];
            }
            if (isset($vals['createdate'])) {
                $this->createdate = $vals['createdate'];
            }
            if (isset($vals['updatedate'])) {
                $this->updatedate = $vals['updatedate'];
            }
            if (isset($vals['question'])) {
                $this->question = $vals['question'];
            }
            if (isset($vals['dict'])) {
                $this->dict = $vals['dict'];
            }
        }
    }

    public function getName()
    {
        return 'IntentSlot';
    }


    public function read($input)
    {
        $xfer = 0;
        $fname = null;
        $ftype = 0;
        $fid = 0;
        $xfer += $input->readStructBegin($fname);
        while (true) {
            $xfer += $input->readFieldBegin($fname, $ftype, $fid);
            if ($ftype == TType::STOP) {
                break;
            }
            switch ($fid) {
                case 1:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->intent_id);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 2:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 3:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->dict_id);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 4:
                    if ($ftype == TType::BOOL) {
                        $xfer += $input->readBool($this->requires);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 5:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->id);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 6:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->createdate);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 7:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->updatedate);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 8:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->question);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 9:
                    if ($ftype == TType::STRUCT) {
                        $this->dict = new \Dict();
                        $xfer += $this->dict->read($input);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                default:
                    $xfer += $input->skip($ftype);
                    break;
            }
            $xfer += $input->readFieldEnd();
        }
        $xfer += $input->readStructEnd();
        return $xfer;
    }

    public function write($output)
    {
        $xfer = 0;
        $xfer += $output->writeStructBegin('IntentSlot');
        if ($this->intent_id !== null) {
            $xfer += $output->writeFieldBegin('intent_id', TType::STRING, 1);
            $xfer += $output->writeString($this->intent_id);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->name !== null) {
            $xfer += $output->writeFieldBegin('name', TType::STRING, 2);
            $xfer += $output->writeString($this->name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->dict_id !== null) {
            $xfer += $output->writeFieldBegin('dict_id', TType::STRING, 3);
            $xfer += $output->writeString($this->dict_id);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->requires !== null) {
            $xfer += $output->writeFieldBegin('requires', TType::BOOL, 4);
            $xfer += $output->writeBool($this->requires);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->id !== null) {
            $xfer += $output->writeFieldBegin('id', TType::STRING, 5);
            $xfer += $output->writeString($this->id);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->createdate !== null) {
            $xfer += $output->writeFieldBegin('createdate', TType::STRING, 6);
            $xfer += $output->writeString($this->createdate);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->updatedate !== null) {
            $xfer += $output->writeFieldBegin('updatedate', TType::STRING, 7);
            $xfer += $output->writeString($this->updatedate);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->question !== null) {
            $xfer += $output->writeFieldBegin('question', TType::STRING, 8);
            $xfer += $output->writeString($this->question);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->dict !== null) {
            if (!is_object($this->dict)) {
                throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
            }
            $xfer += $output->writeFieldBegin('dict', TType::STRUCT, 9);
            $xfer += $this->dict->write($output);
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
