/**
 * 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 SlicePredicate is similar to a mathematic predicate (see http://en.wikipedia.org/wiki/Predicate_(mathematical_logic)),
  /// which is described as "a property that the elements of a set have in common."
  /// 
  /// SlicePredicate's in Cassandra are described with either a list of column_names or a SliceRange.  If column_names is
  /// specified, slice_range is ignored.
  /// 
  /// @param column_name. A list of column names to retrieve. This can be used similar to Memcached's "multi-get" feature
  ///                     to fetch N known column names. For instance, if you know you wish to fetch columns 'Joe', 'Jack',
  ///                     and 'Jim' you can pass those column names as a list to fetch all three at once.
  /// @param slice_range. A SliceRange describing how to range, order, and/or limit the slice.
  /// </summary>
  [DataContract(Namespace="")]
  public partial class SlicePredicate : TBase
  {
    private List<byte[]> _column_names;
    private global::Apache.Cassandra.Test.SliceRange _slice_range;

    [DataMember(Order = 0)]
    public List<byte[]> Column_names
    {
      get
      {
        return _column_names;
      }
      set
      {
        __isset.column_names = true;
        this._column_names = value;
      }
    }

    [DataMember(Order = 0)]
    public global::Apache.Cassandra.Test.SliceRange Slice_range
    {
      get
      {
        return _slice_range;
      }
      set
      {
        __isset.slice_range = true;
        this._slice_range = value;
      }
    }


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

    #region XmlSerializer support

    public bool ShouldSerializeColumn_names()
    {
      return __isset.column_names;
    }

    public bool ShouldSerializeSlice_range()
    {
      return __isset.slice_range;
    }

    #endregion XmlSerializer support

    public SlicePredicate()
    {
    }

    public SlicePredicate DeepCopy()
    {
      var tmp38 = new SlicePredicate();
      if((Column_names != null) && __isset.column_names)
      {
        tmp38.Column_names = this.Column_names.DeepCopy();
      }
      tmp38.__isset.column_names = this.__isset.column_names;
      if((Slice_range != null) && __isset.slice_range)
      {
        tmp38.Slice_range = (global::Apache.Cassandra.Test.SliceRange)this.Slice_range.DeepCopy();
      }
      tmp38.__isset.slice_range = this.__isset.slice_range;
      return tmp38;
    }

    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.List)
              {
                {
                  TList _list39 = await iprot.ReadListBeginAsync(cancellationToken);
                  Column_names = new List<byte[]>(_list39.Count);
                  for(int _i40 = 0; _i40 < _list39.Count; ++_i40)
                  {
                    byte[] _elem41;
                    _elem41 = await iprot.ReadBinaryAsync(cancellationToken);
                    Column_names.Add(_elem41);
                  }
                  await iprot.ReadListEndAsync(cancellationToken);
                }
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.Struct)
              {
                Slice_range = new global::Apache.Cassandra.Test.SliceRange();
                await Slice_range.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("SlicePredicate");
        await oprot.WriteStructBeginAsync(struc, cancellationToken);
        var field = new TField();
        if((Column_names != null) && __isset.column_names)
        {
          field.Name = "column_names";
          field.Type = TType.List;
          field.ID = 1;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          {
            await oprot.WriteListBeginAsync(new TList(TType.String, Column_names.Count), cancellationToken);
            foreach (byte[] _iter42 in Column_names)
            {
              await oprot.WriteBinaryAsync(_iter42, cancellationToken);
            }
            await oprot.WriteListEndAsync(cancellationToken);
          }
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Slice_range != null) && __isset.slice_range)
        {
          field.Name = "slice_range";
          field.Type = TType.Struct;
          field.ID = 2;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await Slice_range.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 SlicePredicate other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return ((__isset.column_names == other.__isset.column_names) && ((!__isset.column_names) || (TCollections.Equals(Column_names, other.Column_names))))
        && ((__isset.slice_range == other.__isset.slice_range) && ((!__isset.slice_range) || (System.Object.Equals(Slice_range, other.Slice_range))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if((Column_names != null) && __isset.column_names)
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(Column_names);
        }
        if((Slice_range != null) && __isset.slice_range)
        {
          hashcode = (hashcode * 397) + Slice_range.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var sb = new StringBuilder("SlicePredicate(");
      int tmp43 = 0;
      if((Column_names != null) && __isset.column_names)
      {
        if(0 < tmp43++) { sb.Append(", "); }
        sb.Append("Column_names: ");
        Column_names.ToString(sb);
      }
      if((Slice_range != null) && __isset.slice_range)
      {
        if(0 < tmp43++) { sb.Append(", "); }
        sb.Append("Slice_range: ");
        Slice_range.ToString(sb);
      }
      sb.Append(')');
      return sb.ToString();
    }
  }

}
