/**
 * 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 EndpointDetails : TBase
  {
    private string _host;
    private string _datacenter;
    private string _rack;

    [DataMember(Order = 0)]
    public string Host
    {
      get
      {
        return _host;
      }
      set
      {
        __isset.host = true;
        this._host = value;
      }
    }

    [DataMember(Order = 0)]
    public string Datacenter
    {
      get
      {
        return _datacenter;
      }
      set
      {
        __isset.datacenter = true;
        this._datacenter = value;
      }
    }

    [DataMember(Order = 0)]
    public string Rack
    {
      get
      {
        return _rack;
      }
      set
      {
        __isset.rack = true;
        this._rack = value;
      }
    }


    [DataMember(Order = 1)]
    public Isset __isset;
    [DataContract]
    public struct Isset
    {
      [DataMember]
      public bool host;
      [DataMember]
      public bool datacenter;
      [DataMember]
      public bool rack;
    }

    #region XmlSerializer support

    public bool ShouldSerializeHost()
    {
      return __isset.host;
    }

    public bool ShouldSerializeDatacenter()
    {
      return __isset.datacenter;
    }

    public bool ShouldSerializeRack()
    {
      return __isset.rack;
    }

    #endregion XmlSerializer support

    public EndpointDetails()
    {
    }

    public EndpointDetails DeepCopy()
    {
      var tmp66 = new EndpointDetails();
      if((Host != null) && __isset.host)
      {
        tmp66.Host = this.Host;
      }
      tmp66.__isset.host = this.__isset.host;
      if((Datacenter != null) && __isset.datacenter)
      {
        tmp66.Datacenter = this.Datacenter;
      }
      tmp66.__isset.datacenter = this.__isset.datacenter;
      if((Rack != null) && __isset.rack)
      {
        tmp66.Rack = this.Rack;
      }
      tmp66.__isset.rack = this.__isset.rack;
      return tmp66;
    }

    public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
    {
      iprot.IncrementRecursionDepth();
      try
      {
        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.String)
              {
                Host = await iprot.ReadStringAsync(cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.String)
              {
                Datacenter = await iprot.ReadStringAsync(cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 3:
              if (field.Type == TType.String)
              {
                Rack = await iprot.ReadStringAsync(cancellationToken);
              }
              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);
      }
      finally
      {
        iprot.DecrementRecursionDepth();
      }
    }

    public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
    {
      oprot.IncrementRecursionDepth();
      try
      {
        var struc = new TStruct("EndpointDetails");
        await oprot.WriteStructBeginAsync(struc, cancellationToken);
        var field = new TField();
        if((Host != null) && __isset.host)
        {
          field.Name = "host";
          field.Type = TType.String;
          field.ID = 1;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await oprot.WriteStringAsync(Host, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Datacenter != null) && __isset.datacenter)
        {
          field.Name = "datacenter";
          field.Type = TType.String;
          field.ID = 2;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await oprot.WriteStringAsync(Datacenter, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Rack != null) && __isset.rack)
        {
          field.Name = "rack";
          field.Type = TType.String;
          field.ID = 3;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await oprot.WriteStringAsync(Rack, 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 EndpointDetails other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return ((__isset.host == other.__isset.host) && ((!__isset.host) || (System.Object.Equals(Host, other.Host))))
        && ((__isset.datacenter == other.__isset.datacenter) && ((!__isset.datacenter) || (System.Object.Equals(Datacenter, other.Datacenter))))
        && ((__isset.rack == other.__isset.rack) && ((!__isset.rack) || (System.Object.Equals(Rack, other.Rack))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if((Host != null) && __isset.host)
        {
          hashcode = (hashcode * 397) + Host.GetHashCode();
        }
        if((Datacenter != null) && __isset.datacenter)
        {
          hashcode = (hashcode * 397) + Datacenter.GetHashCode();
        }
        if((Rack != null) && __isset.rack)
        {
          hashcode = (hashcode * 397) + Rack.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var sb = new StringBuilder("EndpointDetails(");
      int tmp67 = 0;
      if((Host != null) && __isset.host)
      {
        if(0 < tmp67++) { sb.Append(", "); }
        sb.Append("Host: ");
        Host.ToString(sb);
      }
      if((Datacenter != null) && __isset.datacenter)
      {
        if(0 < tmp67++) { sb.Append(", "); }
        sb.Append("Datacenter: ");
        Datacenter.ToString(sb);
      }
      if((Rack != null) && __isset.rack)
      {
        if(0 < tmp67++) { sb.Append(", "); }
        sb.Append("Rack: ");
        Rack.ToString(sb);
      }
      sb.Append(')');
      return sb.ToString();
    }
  }

}
