using System.Collections.Generic;

namespace QC.QsprTestObjects.Metadata;

public class MetadataItems
{
	public List<MetadataItem> Items { get; set; }

	public MetadataItems()
	{
		Items = new List<MetadataItem>();
	}

	public MetadataItems Clone()
	{
		MetadataItems metadataItems = new MetadataItems();
		foreach (MetadataItem item in Items)
		{
			metadataItems.Items.Add(item.Clone());
		}
		return metadataItems;
	}

	public bool ContainsName(string name)
	{
		foreach (MetadataItem item in Items)
		{
			if (item.Name.ToUpper() == name.ToUpper())
			{
				return true;
			}
		}
		return false;
	}

	public bool ContainsParameter(string paramName, string testIndex, int arrayIndex = -2)
	{
		foreach (MetadataItem item in Items)
		{
			if (item.Type == MetadataItem.MetadataType.TestParameter && item.TestIndex == testIndex && item.SourceName == paramName && item.ArrayIndex == arrayIndex)
			{
				return true;
			}
		}
		return false;
	}

	public bool ContainsGlobalVariable(string globalName)
	{
		foreach (MetadataItem item in Items)
		{
			if (item.Type == MetadataItem.MetadataType.GlobalVariable && item.SourceName == globalName)
			{
				return true;
			}
		}
		return false;
	}
}
