using System;
using System.ComponentModel;

namespace Azure.Iot.Hub.Service.Models
{
    /// <summary> The DeviceStatus. </summary>
    public readonly partial struct DeviceStatus : IEquatable<DeviceStatus>
    {
        private readonly string _value;

        /// <summary> Determines if two <see cref="DeviceStatus"/> values are the same. </summary>
        public DeviceStatus(string value)
        {
            _value = value ?? throw new ArgumentNullException(nameof(value));
        }

        private const string EnabledValue = "enabled";
        private const string DisabledValue = "disabled";

        /// <summary> enabled. </summary>
        public static DeviceStatus Enabled { get; } = new DeviceStatus(EnabledValue);
        /// <summary> disabled. </summary>
        public static DeviceStatus Disabled { get; } = new DeviceStatus(DisabledValue);
        /// <summary> Determines if two <see cref="DeviceStatus"/> values are the same. </summary>
        public static bool operator ==(DeviceStatus left, DeviceStatus right) => left.Equals(right);
        /// <summary> Determines if two <see cref="DeviceStatus"/> values are not the same. </summary>
        public static bool operator !=(DeviceStatus left, DeviceStatus right) => !left.Equals(right);
        /// <summary> Converts a string to a <see cref="DeviceStatus"/>. </summary>
        public static implicit operator DeviceStatus(string value) => new DeviceStatus(value);

        /// <inheritdoc />
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override bool Equals(object obj) => obj is DeviceStatus other && Equals(other);
        /// <inheritdoc />
        public bool Equals(DeviceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

        /// <inheritdoc />
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override int GetHashCode() => _value?.GetHashCode() ?? 0;
        /// <inheritdoc />
        public override string ToString() => _value;
    }
}
