﻿/*
 * THIS FILE WAS GENERATED BY PLOTLY.BLAZOR.GENERATOR
*/

using System;
{{#HasList}}
using System.Collections.Generic;
{{/HasList}}
using System.Diagnostics.CodeAnalysis;
using System.IO;
{{#HasList}}
using System.Linq;
{{/HasList}}
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.Json.Serialization;

namespace {{Namespace}}
{
    /// <summary>
    {{#Description}}
    ///     {{.}}
    {{/Description}}
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("{{GeneratorName}}", null)]
    {{#HasSpecialProperties}}
    [JsonConverter(typeof(PlotlyConverter))]
    {{/HasSpecialProperties}}
    [Serializable]
    public class {{Name}} : {{#Interface}}{{.}}, {{/Interface}}IEquatable<{{Name}}>
    {
        {{#Properties}}
        {{#IsInherited}}
        /// <inheritdoc/>
        {{/IsInherited}}
        {{^IsInherited}}
        /// <summary>
        {{#PropertyDescription}}
        ///     {{.}}
        {{/PropertyDescription}}
        /// </summary>
        {{/IsInherited}}
        [JsonPropertyName(@"{{DisplayName}}")]
        {{#IsArrayOk}}
        [Array]
        {{/IsArrayOk}}
        {{#IsSubplot}}
        [Subplot]
        {{/IsSubplot}}
        public {{TypeName}} {{PropertyName}} { get; {{^IsReadOnly}}set;{{/IsReadOnly}}} {{#DefaultValue}}= {{.}};{{/DefaultValue}}

        {{/Properties}}
        /// <inheritdoc />
        public override bool Equals(object obj)
        {
            if (!(obj is {{Name}} other)) return false;

            return ReferenceEquals(this, obj) || Equals(other);
        }

        /// <inheritdoc />
        public bool Equals([AllowNull] {{Name}} other)
        {
            if (other == null) return false;
            if (ReferenceEquals(this, other)) return true;

            return {{^Properties}}true;{{/Properties}}
{{#Properties}}
{{^IsList}}
                (
                    {{PropertyName}} == other.{{PropertyName}} ||
                    {{PropertyName}} != null &&
                    {{PropertyName}}.Equals(other.{{PropertyName}})
                ){{#HasMore}} && {{/HasMore}}{{^HasMore}};{{/HasMore}}
{{/IsList}}
{{#IsList}}
                (
                    Equals({{PropertyName}}, other.{{PropertyName}}) ||
                    {{PropertyName}} != null && other.{{PropertyName}} != null &&
                    {{PropertyName}}.SequenceEqual(other.{{PropertyName}})
                ){{#HasMore}} &&{{/HasMore}}{{^HasMore}};{{/HasMore}}
{{/IsList}}
{{/Properties}}
        }

        /// <inheritdoc />
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
{{#Properties}}
                if ({{PropertyName}} != null) hashCode = hashCode * 59 + {{PropertyName}}.GetHashCode();
{{/Properties}}
                return hashCode;
            }
        }

        /// <summary>
        ///     Checks for equality of the left {{Name}} and the right {{Name}}.
        /// </summary>
        /// <param name="left">Left {{Name}}.</param>
        /// <param name="right">Right {{Name}}.</param>
        /// <returns>Boolean</returns>
        public static bool operator == ({{Name}} left, {{Name}} right)
        {
            return Equals(left, right);
        }

        /// <summary>
        ///     Checks for inequality of the left {{Name}} and the right {{Name}}.
        /// </summary>
        /// <param name="left">Left {{Name}}.</param>
        /// <param name="right">Right {{Name}}.</param>
        /// <returns>Boolean</returns>
        public static bool operator != ({{Name}} left, {{Name}} right)
        {
            return !Equals(left, right);
        }

        /// <summary>
        ///     Gets a deep copy of this instance.
        /// </summary>
        /// <returns>{{Name}}</returns>
        public {{Name}} DeepClone()
        {
            return this.Copy();
        }
    }
}