// Created with MonoDevelop
//
//    Copyright (C) 2017 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.



using System;
using System.Collections.Generic;


namespace Hiperscan.Pdf.SubstanceOverview
{
	
	public class GranulateEntry : IEquatable<GranulateEntry>
	{
		public GranulateEntry ()
		{
			this.DefaultNames 	= new List<string>();
			this.LatinNames		= new List<string>();
			this.ChinaMedica	= false;
			this.HerbaSinica	= false;
			this.PhytoComm		= false;
		}
		
		public GranulateEntry Clone()
		{
			GranulateEntry clone = new GranulateEntry();
			clone.DefaultNames 	= this.DefaultNames;
			clone.LatinNames	= this.LatinNames;
			clone.ChinaMedica	= this.ChinaMedica;
			clone.HerbaSinica	= this.HerbaSinica;
			clone.PhytoComm		= this.PhytoComm;
			return clone;
		}
		
		public List<string> DefaultNames 	{get; set;}
		public List<string>	LatinNames		{get; set;}
		public bool ChinaMedica				{get; set;}
		public bool HerbaSinica				{get; set;}
		public bool PhytoComm				{get; set;}
	

		#region IEquatable[GranulateEntry] implementation
		public bool Equals (GranulateEntry other)
		{
			foreach (string default_name in this.DefaultNames)
			{
				if (other.DefaultNames.Contains(default_name) == true)
					return true;
			}
			
			return false;
		}
		#endregion
	}
	
	public class DefaultNameComparer : IComparer<GranulateEntry>
	{
		#region IComparer[GranulateEntry] implementation
		public int Compare (GranulateEntry x, GranulateEntry y)
		{
			return x.DefaultNames[0].CompareTo(y.DefaultNames[0]);
		}
		#endregion
	}
	
	public class LatinNameComparer : IComparer<GranulateEntry>
	{
		#region IComparer[GranulateEntry] implementation
		public int Compare (GranulateEntry x, GranulateEntry y)
		{
			return x.LatinNames[0].CompareTo(y.LatinNames[0]);
		}
		#endregion
	}
}

