<?php
namespace metastore;

/**
 * Autogenerated by Thrift Compiler (0.16.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 SQLForeignKey
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'pktable_db',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        2 => array(
            'var' => 'pktable_name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        3 => array(
            'var' => 'pkcolumn_name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        4 => array(
            'var' => 'fktable_db',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        5 => array(
            'var' => 'fktable_name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        6 => array(
            'var' => 'fkcolumn_name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        7 => array(
            'var' => 'key_seq',
            'isRequired' => false,
            'type' => TType::I32,
        ),
        8 => array(
            'var' => 'update_rule',
            'isRequired' => false,
            'type' => TType::I32,
        ),
        9 => array(
            'var' => 'delete_rule',
            'isRequired' => false,
            'type' => TType::I32,
        ),
        10 => array(
            'var' => 'fk_name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        11 => array(
            'var' => 'pk_name',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
        12 => array(
            'var' => 'enable_cstr',
            'isRequired' => false,
            'type' => TType::BOOL,
        ),
        13 => array(
            'var' => 'validate_cstr',
            'isRequired' => false,
            'type' => TType::BOOL,
        ),
        14 => array(
            'var' => 'rely_cstr',
            'isRequired' => false,
            'type' => TType::BOOL,
        ),
        15 => array(
            'var' => 'catName',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
    );

    /**
     * @var string
     */
    public $pktable_db = null;
    /**
     * @var string
     */
    public $pktable_name = null;
    /**
     * @var string
     */
    public $pkcolumn_name = null;
    /**
     * @var string
     */
    public $fktable_db = null;
    /**
     * @var string
     */
    public $fktable_name = null;
    /**
     * @var string
     */
    public $fkcolumn_name = null;
    /**
     * @var int
     */
    public $key_seq = null;
    /**
     * @var int
     */
    public $update_rule = null;
    /**
     * @var int
     */
    public $delete_rule = null;
    /**
     * @var string
     */
    public $fk_name = null;
    /**
     * @var string
     */
    public $pk_name = null;
    /**
     * @var bool
     */
    public $enable_cstr = null;
    /**
     * @var bool
     */
    public $validate_cstr = null;
    /**
     * @var bool
     */
    public $rely_cstr = null;
    /**
     * @var string
     */
    public $catName = null;

    public function __construct($vals = null)
    {
        if (is_array($vals)) {
            if (isset($vals['pktable_db'])) {
                $this->pktable_db = $vals['pktable_db'];
            }
            if (isset($vals['pktable_name'])) {
                $this->pktable_name = $vals['pktable_name'];
            }
            if (isset($vals['pkcolumn_name'])) {
                $this->pkcolumn_name = $vals['pkcolumn_name'];
            }
            if (isset($vals['fktable_db'])) {
                $this->fktable_db = $vals['fktable_db'];
            }
            if (isset($vals['fktable_name'])) {
                $this->fktable_name = $vals['fktable_name'];
            }
            if (isset($vals['fkcolumn_name'])) {
                $this->fkcolumn_name = $vals['fkcolumn_name'];
            }
            if (isset($vals['key_seq'])) {
                $this->key_seq = $vals['key_seq'];
            }
            if (isset($vals['update_rule'])) {
                $this->update_rule = $vals['update_rule'];
            }
            if (isset($vals['delete_rule'])) {
                $this->delete_rule = $vals['delete_rule'];
            }
            if (isset($vals['fk_name'])) {
                $this->fk_name = $vals['fk_name'];
            }
            if (isset($vals['pk_name'])) {
                $this->pk_name = $vals['pk_name'];
            }
            if (isset($vals['enable_cstr'])) {
                $this->enable_cstr = $vals['enable_cstr'];
            }
            if (isset($vals['validate_cstr'])) {
                $this->validate_cstr = $vals['validate_cstr'];
            }
            if (isset($vals['rely_cstr'])) {
                $this->rely_cstr = $vals['rely_cstr'];
            }
            if (isset($vals['catName'])) {
                $this->catName = $vals['catName'];
            }
        }
    }

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


    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->pktable_db);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 2:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->pktable_name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 3:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->pkcolumn_name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 4:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->fktable_db);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 5:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->fktable_name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 6:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->fkcolumn_name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 7:
                    if ($ftype == TType::I32) {
                        $xfer += $input->readI32($this->key_seq);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 8:
                    if ($ftype == TType::I32) {
                        $xfer += $input->readI32($this->update_rule);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 9:
                    if ($ftype == TType::I32) {
                        $xfer += $input->readI32($this->delete_rule);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 10:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->fk_name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 11:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->pk_name);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 12:
                    if ($ftype == TType::BOOL) {
                        $xfer += $input->readBool($this->enable_cstr);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 13:
                    if ($ftype == TType::BOOL) {
                        $xfer += $input->readBool($this->validate_cstr);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 14:
                    if ($ftype == TType::BOOL) {
                        $xfer += $input->readBool($this->rely_cstr);
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 15:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->catName);
                    } 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('SQLForeignKey');
        if ($this->pktable_db !== null) {
            $xfer += $output->writeFieldBegin('pktable_db', TType::STRING, 1);
            $xfer += $output->writeString($this->pktable_db);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->pktable_name !== null) {
            $xfer += $output->writeFieldBegin('pktable_name', TType::STRING, 2);
            $xfer += $output->writeString($this->pktable_name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->pkcolumn_name !== null) {
            $xfer += $output->writeFieldBegin('pkcolumn_name', TType::STRING, 3);
            $xfer += $output->writeString($this->pkcolumn_name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->fktable_db !== null) {
            $xfer += $output->writeFieldBegin('fktable_db', TType::STRING, 4);
            $xfer += $output->writeString($this->fktable_db);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->fktable_name !== null) {
            $xfer += $output->writeFieldBegin('fktable_name', TType::STRING, 5);
            $xfer += $output->writeString($this->fktable_name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->fkcolumn_name !== null) {
            $xfer += $output->writeFieldBegin('fkcolumn_name', TType::STRING, 6);
            $xfer += $output->writeString($this->fkcolumn_name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->key_seq !== null) {
            $xfer += $output->writeFieldBegin('key_seq', TType::I32, 7);
            $xfer += $output->writeI32($this->key_seq);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->update_rule !== null) {
            $xfer += $output->writeFieldBegin('update_rule', TType::I32, 8);
            $xfer += $output->writeI32($this->update_rule);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->delete_rule !== null) {
            $xfer += $output->writeFieldBegin('delete_rule', TType::I32, 9);
            $xfer += $output->writeI32($this->delete_rule);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->fk_name !== null) {
            $xfer += $output->writeFieldBegin('fk_name', TType::STRING, 10);
            $xfer += $output->writeString($this->fk_name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->pk_name !== null) {
            $xfer += $output->writeFieldBegin('pk_name', TType::STRING, 11);
            $xfer += $output->writeString($this->pk_name);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->enable_cstr !== null) {
            $xfer += $output->writeFieldBegin('enable_cstr', TType::BOOL, 12);
            $xfer += $output->writeBool($this->enable_cstr);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->validate_cstr !== null) {
            $xfer += $output->writeFieldBegin('validate_cstr', TType::BOOL, 13);
            $xfer += $output->writeBool($this->validate_cstr);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->rely_cstr !== null) {
            $xfer += $output->writeFieldBegin('rely_cstr', TType::BOOL, 14);
            $xfer += $output->writeBool($this->rely_cstr);
            $xfer += $output->writeFieldEnd();
        }
        if ($this->catName !== null) {
            $xfer += $output->writeFieldBegin('catName', TType::STRING, 15);
            $xfer += $output->writeString($this->catName);
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
