/**
 * Autogenerated by Thrift Compiler (0.14.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Thrift;
using Thrift.Collections;
using System.ServiceModel;
using System.Runtime.Serialization;

using Thrift.Protocol;
using Thrift.Protocol.Entities;
using Thrift.Protocol.Utilities;
using Thrift.Transport;
using Thrift.Transport.Client;
using Thrift.Transport.Server;
using Thrift.Processor;


#pragma warning disable IDE0079  // remove unnecessary pragmas
#pragma warning disable IDE1006  // parts of the code use IDL spelling

namespace Apache.Cassandra.Test
{

  [DataContract(Namespace="")]
  public partial class CqlMetadata : TBase
  {

    [DataMember(Order = 0)]
    public Dictionary<byte[], string> Name_types { get; set; }

    [DataMember(Order = 0)]
    public Dictionary<byte[], string> Value_types { get; set; }

    [DataMember(Order = 0)]
    public string Default_name_type { get; set; }

    [DataMember(Order = 0)]
    public string Default_value_type { get; set; }

    public CqlMetadata()
    {
    }

    public CqlMetadata(Dictionary<byte[], string> name_types, Dictionary<byte[], string> value_types, string default_name_type, string default_value_type) : this()
    {
      this.Name_types = name_types;
      this.Value_types = value_types;
      this.Default_name_type = default_name_type;
      this.Default_value_type = default_value_type;
    }

    public CqlMetadata DeepCopy()
    {
      var tmp129 = new CqlMetadata();
      if((Name_types != null))
      {
        tmp129.Name_types = this.Name_types.DeepCopy();
      }
      if((Value_types != null))
      {
        tmp129.Value_types = this.Value_types.DeepCopy();
      }
      if((Default_name_type != null))
      {
        tmp129.Default_name_type = this.Default_name_type;
      }
      if((Default_value_type != null))
      {
        tmp129.Default_value_type = this.Default_value_type;
      }
      return tmp129;
    }

    public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
    {
      iprot.IncrementRecursionDepth();
      try
      {
        bool isset_name_types = false;
        bool isset_value_types = false;
        bool isset_default_name_type = false;
        bool isset_default_value_type = false;
        TField field;
        await iprot.ReadStructBeginAsync(cancellationToken);
        while (true)
        {
          field = await iprot.ReadFieldBeginAsync(cancellationToken);
          if (field.Type == TType.Stop)
          {
            break;
          }

          switch (field.ID)
          {
            case 1:
              if (field.Type == TType.Map)
              {
                {
                  TMap _map130 = await iprot.ReadMapBeginAsync(cancellationToken);
                  Name_types = new Dictionary<byte[], string>(_map130.Count);
                  for(int _i131 = 0; _i131 < _map130.Count; ++_i131)
                  {
                    byte[] _key132;
                    string _val133;
                    _key132 = await iprot.ReadBinaryAsync(cancellationToken);
                    _val133 = await iprot.ReadStringAsync(cancellationToken);
                    Name_types[_key132] = _val133;
                  }
                  await iprot.ReadMapEndAsync(cancellationToken);
                }
                isset_name_types = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.Map)
              {
                {
                  TMap _map134 = await iprot.ReadMapBeginAsync(cancellationToken);
                  Value_types = new Dictionary<byte[], string>(_map134.Count);
                  for(int _i135 = 0; _i135 < _map134.Count; ++_i135)
                  {
                    byte[] _key136;
                    string _val137;
                    _key136 = await iprot.ReadBinaryAsync(cancellationToken);
                    _val137 = await iprot.ReadStringAsync(cancellationToken);
                    Value_types[_key136] = _val137;
                  }
                  await iprot.ReadMapEndAsync(cancellationToken);
                }
                isset_value_types = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 3:
              if (field.Type == TType.String)
              {
                Default_name_type = await iprot.ReadStringAsync(cancellationToken);
                isset_default_name_type = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 4:
              if (field.Type == TType.String)
              {
                Default_value_type = await iprot.ReadStringAsync(cancellationToken);
                isset_default_value_type = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            default: 
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              break;
          }

          await iprot.ReadFieldEndAsync(cancellationToken);
        }

        await iprot.ReadStructEndAsync(cancellationToken);
        if (!isset_name_types)
        {
          throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
        if (!isset_value_types)
        {
          throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
        if (!isset_default_name_type)
        {
          throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
        if (!isset_default_value_type)
        {
          throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
      }
      finally
      {
        iprot.DecrementRecursionDepth();
      }
    }

    public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
    {
      oprot.IncrementRecursionDepth();
      try
      {
        var struc = new TStruct("CqlMetadata");
        await oprot.WriteStructBeginAsync(struc, cancellationToken);
        var field = new TField();
        if((Name_types != null))
        {
          field.Name = "name_types";
          field.Type = TType.Map;
          field.ID = 1;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          {
            await oprot.WriteMapBeginAsync(new TMap(TType.String, TType.String, Name_types.Count), cancellationToken);
            foreach (byte[] _iter138 in Name_types.Keys)
            {
              await oprot.WriteBinaryAsync(_iter138, cancellationToken);
              await oprot.WriteStringAsync(Name_types[_iter138], cancellationToken);
            }
            await oprot.WriteMapEndAsync(cancellationToken);
          }
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Value_types != null))
        {
          field.Name = "value_types";
          field.Type = TType.Map;
          field.ID = 2;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          {
            await oprot.WriteMapBeginAsync(new TMap(TType.String, TType.String, Value_types.Count), cancellationToken);
            foreach (byte[] _iter139 in Value_types.Keys)
            {
              await oprot.WriteBinaryAsync(_iter139, cancellationToken);
              await oprot.WriteStringAsync(Value_types[_iter139], cancellationToken);
            }
            await oprot.WriteMapEndAsync(cancellationToken);
          }
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Default_name_type != null))
        {
          field.Name = "default_name_type";
          field.Type = TType.String;
          field.ID = 3;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await oprot.WriteStringAsync(Default_name_type, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Default_value_type != null))
        {
          field.Name = "default_value_type";
          field.Type = TType.String;
          field.ID = 4;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await oprot.WriteStringAsync(Default_value_type, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        await oprot.WriteFieldStopAsync(cancellationToken);
        await oprot.WriteStructEndAsync(cancellationToken);
      }
      finally
      {
        oprot.DecrementRecursionDepth();
      }
    }

    public override bool Equals(object that)
    {
      if (!(that is CqlMetadata other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return TCollections.Equals(Name_types, other.Name_types)
        && TCollections.Equals(Value_types, other.Value_types)
        && System.Object.Equals(Default_name_type, other.Default_name_type)
        && System.Object.Equals(Default_value_type, other.Default_value_type);
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if((Name_types != null))
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(Name_types);
        }
        if((Value_types != null))
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(Value_types);
        }
        if((Default_name_type != null))
        {
          hashcode = (hashcode * 397) + Default_name_type.GetHashCode();
        }
        if((Default_value_type != null))
        {
          hashcode = (hashcode * 397) + Default_value_type.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var sb = new StringBuilder("CqlMetadata(");
      if((Name_types != null))
      {
        sb.Append(", Name_types: ");
        Name_types.ToString(sb);
      }
      if((Value_types != null))
      {
        sb.Append(", Value_types: ");
        Value_types.ToString(sb);
      }
      if((Default_name_type != null))
      {
        sb.Append(", Default_name_type: ");
        Default_name_type.ToString(sb);
      }
      if((Default_value_type != null))
      {
        sb.Append(", Default_value_type: ");
        Default_value_type.ToString(sb);
      }
      sb.Append(')');
      return sb.ToString();
    }
  }

}
