using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Serialization;

namespace QC.QSPRLogSchema;

[Serializable]
[XmlType(AnonymousType = true)]
public class ArrayOutputItem : IEquatable<ArrayOutputItem>
{
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string valField;

	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private List<ArrayOutputLimitItem> limField;

	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string nField;

	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string uField;

	[XmlAttribute("N")]
	public string Name
	{
		get
		{
			return nField;
		}
		set
		{
			nField = value;
		}
	}

	[XmlElement("Val")]
	public string Value
	{
		get
		{
			return valField;
		}
		set
		{
			valField = value;
		}
	}

	[XmlAttribute("U")]
	public string Unit
	{
		get
		{
			return uField;
		}
		set
		{
			uField = value;
		}
	}

	[XmlElement("Lim")]
	public List<ArrayOutputLimitItem> Limits
	{
		get
		{
			return limField;
		}
		set
		{
			limField = value;
		}
	}

	[XmlAttribute("RE")]
	public string ReportingEnabled { get; set; }

	public bool ShouldSerializeName()
	{
		return !string.IsNullOrEmpty(Name);
	}

	public bool ShouldSerializeValue()
	{
		return !string.IsNullOrEmpty(Value);
	}

	public bool ShouldSerializeUnit()
	{
		return !string.IsNullOrEmpty(Unit);
	}

	public bool ShouldSerializeLimits()
	{
		if (Limits != null)
		{
			return Limits.Count > 0;
		}
		return false;
	}

	public ArrayOutputItem()
	{
		valField = string.Empty;
		limField = new List<ArrayOutputLimitItem>();
		nField = string.Empty;
		uField = string.Empty;
	}

	public ArrayOutputItem(string val = null, List<ArrayOutputLimitItem> lim = null, string n = null, string u = null)
	{
		if (!string.IsNullOrEmpty(val))
		{
			valField = val;
		}
		else
		{
			valField = string.Empty;
		}
		if (lim != null)
		{
			limField = lim;
		}
		else
		{
			limField = new List<ArrayOutputLimitItem>();
		}
		if (!string.IsNullOrEmpty(n))
		{
			nField = n;
		}
		else
		{
			nField = string.Empty;
		}
		if (!string.IsNullOrEmpty(u))
		{
			uField = u;
		}
		else
		{
			uField = string.Empty;
		}
	}

	public bool Equals(ArrayOutputItem other)
	{
		bool result = false;
		if (Name.Equals(other.Name) && Value.Equals(other.Value) && Unit.Equals(other.Unit))
		{
			if (Limits.Count == other.Limits.Count)
			{
				foreach (ArrayOutputLimitItem limit in Limits)
				{
					if (!other.Limits.Contains(limit))
					{
						return result;
					}
				}
			}
			result = true;
		}
		return result;
	}
}
