/**
 * 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
{

  /// <summary>
  /// A Mutation is either an insert (represented by filling column_or_supercolumn) or a deletion (represented by filling the deletion attribute).
  /// @param column_or_supercolumn. An insert to a column or supercolumn (possibly counter column or supercolumn)
  /// @param deletion. A deletion of a column or supercolumn
  /// </summary>
  [DataContract(Namespace="")]
  public partial class Mutation : TBase
  {
    private global::Apache.Cassandra.Test.ColumnOrSuperColumn _column_or_supercolumn;
    private global::Apache.Cassandra.Test.Deletion _deletion;

    [DataMember(Order = 0)]
    public global::Apache.Cassandra.Test.ColumnOrSuperColumn Column_or_supercolumn
    {
      get
      {
        return _column_or_supercolumn;
      }
      set
      {
        __isset.column_or_supercolumn = true;
        this._column_or_supercolumn = value;
      }
    }

    [DataMember(Order = 0)]
    public global::Apache.Cassandra.Test.Deletion Deletion
    {
      get
      {
        return _deletion;
      }
      set
      {
        __isset.deletion = true;
        this._deletion = value;
      }
    }


    [DataMember(Order = 1)]
    public Isset __isset;
    [DataContract]
    public struct Isset
    {
      [DataMember]
      public bool column_or_supercolumn;
      [DataMember]
      public bool deletion;
    }

    #region XmlSerializer support

    public bool ShouldSerializeColumn_or_supercolumn()
    {
      return __isset.column_or_supercolumn;
    }

    public bool ShouldSerializeDeletion()
    {
      return __isset.deletion;
    }

    #endregion XmlSerializer support

    public Mutation()
    {
    }

    public Mutation DeepCopy()
    {
      var tmp64 = new Mutation();
      if((Column_or_supercolumn != null) && __isset.column_or_supercolumn)
      {
        tmp64.Column_or_supercolumn = (global::Apache.Cassandra.Test.ColumnOrSuperColumn)this.Column_or_supercolumn.DeepCopy();
      }
      tmp64.__isset.column_or_supercolumn = this.__isset.column_or_supercolumn;
      if((Deletion != null) && __isset.deletion)
      {
        tmp64.Deletion = (global::Apache.Cassandra.Test.Deletion)this.Deletion.DeepCopy();
      }
      tmp64.__isset.deletion = this.__isset.deletion;
      return tmp64;
    }

    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.Struct)
              {
                Column_or_supercolumn = new global::Apache.Cassandra.Test.ColumnOrSuperColumn();
                await Column_or_supercolumn.ReadAsync(iprot, cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.Struct)
              {
                Deletion = new global::Apache.Cassandra.Test.Deletion();
                await Deletion.ReadAsync(iprot, 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("Mutation");
        await oprot.WriteStructBeginAsync(struc, cancellationToken);
        var field = new TField();
        if((Column_or_supercolumn != null) && __isset.column_or_supercolumn)
        {
          field.Name = "column_or_supercolumn";
          field.Type = TType.Struct;
          field.ID = 1;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await Column_or_supercolumn.WriteAsync(oprot, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Deletion != null) && __isset.deletion)
        {
          field.Name = "deletion";
          field.Type = TType.Struct;
          field.ID = 2;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await Deletion.WriteAsync(oprot, 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 Mutation other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return ((__isset.column_or_supercolumn == other.__isset.column_or_supercolumn) && ((!__isset.column_or_supercolumn) || (System.Object.Equals(Column_or_supercolumn, other.Column_or_supercolumn))))
        && ((__isset.deletion == other.__isset.deletion) && ((!__isset.deletion) || (System.Object.Equals(Deletion, other.Deletion))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if((Column_or_supercolumn != null) && __isset.column_or_supercolumn)
        {
          hashcode = (hashcode * 397) + Column_or_supercolumn.GetHashCode();
        }
        if((Deletion != null) && __isset.deletion)
        {
          hashcode = (hashcode * 397) + Deletion.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var sb = new StringBuilder("Mutation(");
      int tmp65 = 0;
      if((Column_or_supercolumn != null) && __isset.column_or_supercolumn)
      {
        if(0 < tmp65++) { sb.Append(", "); }
        sb.Append("Column_or_supercolumn: ");
        Column_or_supercolumn.ToString(sb);
      }
      if((Deletion != null) && __isset.deletion)
      {
        if(0 < tmp65++) { sb.Append(", "); }
        sb.Append("Deletion: ");
        Deletion.ToString(sb);
      }
      sb.Append(')');
      return sb.ToString();
    }
  }

}
