/* 
 * TSE Cloud - CO
 *
 * This is Swagger Docs for Document WebApi Teamsystemn Enterprise Cloud, more detail at [https://swagger.io](https://swagger.io).
 *
 * OpenAPI spec version: v2025.3000
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
    /// <summary>
    /// DTO that identifies a search criteria
    /// </summary>
    [DataContract]
        public partial class SearchElementDTO : SearchNodeDTO,  IEquatable<SearchElementDTO>, IValidatableObject, OneOfSearchGroupDTOItemsItems 
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchElementDTO" /> class.
        /// </summary>
        /// <param name="propertyName">Property on witch apply the filter (required).</param>
        /// <param name="comparer">comparer (required).</param>
        /// <param name="value">value (required).</param>
        public SearchElementDTO(string propertyName = default(string), int? comparer = default(int?), SearchNodeValueDTO value = default(SearchNodeValueDTO), int? _operator = default(int?)) : base(_operator)
        {
            // to ensure "propertyName" is required (not null)
            if (propertyName == null)
            {
                throw new InvalidDataException("propertyName is a required property for SearchElementDTO and cannot be null");
            }
            else
            {
                this.PropertyName = propertyName;
            }
            // to ensure "comparer" is required (not null)
            if (comparer == null)
            {
                throw new InvalidDataException("comparer is a required property for SearchElementDTO and cannot be null");
            }
            else
            {
                this.Comparer = comparer;
            }
            // to ensure "value" is required (not null)
            if (value == null)
            {
                throw new InvalidDataException("value is a required property for SearchElementDTO and cannot be null");
            }
            else
            {
                this.Value = value;
            }
        }
        
        /// <summary>
        /// Property on witch apply the filter
        /// </summary>
        /// <value>Property on witch apply the filter</value>
        [DataMember(Name="propertyName", EmitDefaultValue=false)]
        public string PropertyName { get; set; }

        /// <summary>
        /// Gets or Sets Comparer
        /// </summary>
        [DataMember(Name="comparer", EmitDefaultValue=false)]
        public int? Comparer { get; set; }

        /// <summary>
        /// Gets or Sets Value
        /// </summary>
        [DataMember(Name="value", EmitDefaultValue=false)]
        public SearchNodeValueDTO Value { get; set; }

        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("class SearchElementDTO {\n");
            sb.Append("  ").Append(base.ToString().Replace("\n", "\n  ")).Append("\n");
            sb.Append("  PropertyName: ").Append(PropertyName).Append("\n");
            sb.Append("  Comparer: ").Append(Comparer).Append("\n");
            sb.Append("  Value: ").Append(Value).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }
  
        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public override string ToJson()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as SearchElementDTO);
        }

        /// <summary>
        /// Returns true if SearchElementDTO instances are equal
        /// </summary>
        /// <param name="input">Instance of SearchElementDTO to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SearchElementDTO input)
        {
            if (input == null)
                return false;

            return base.Equals(input) && 
                (
                    this.PropertyName == input.PropertyName ||
                    (this.PropertyName != null &&
                    this.PropertyName.Equals(input.PropertyName))
                ) && base.Equals(input) && 
                (
                    this.Comparer == input.Comparer ||
                    (this.Comparer != null &&
                    this.Comparer.Equals(input.Comparer))
                ) && base.Equals(input) && 
                (
                    this.Value == input.Value ||
                    (this.Value != null &&
                    this.Value.Equals(input.Value))
                );
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = base.GetHashCode();
                if (this.PropertyName != null)
                    hashCode = hashCode * 59 + this.PropertyName.GetHashCode();
                if (this.Comparer != null)
                    hashCode = hashCode * 59 + this.Comparer.GetHashCode();
                if (this.Value != null)
                    hashCode = hashCode * 59 + this.Value.GetHashCode();
                return hashCode;
            }
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            yield break;
        }
    }
}
