using System;
using System.Collections.Generic;
using System.Text;

namespace Howest.SchemaDiscovery.DbObjects
{
	public class Table
	{
		private string _name;

		public string Name
		{
			get { return _name; }
			set { _name = value; }
		}

		private string _fullname;

		public string Fullname
		{
			get { return _fullname; }
			set { _fullname = value; }
		}

		private string _schema;

		public string Schema
		{
			get { return _schema; }
			set { _schema = value; }
		}

		private List<Column> _columns = new List<Column>();

		public List<Column> Columns
		{
			get { return _columns; }
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
				return false;
			if (!(obj is Table))
				return false;
			Table tab = obj as Table;
			/*if (tab == null)
				return false;*/
			return tab.Schema == this.Schema && tab.Name == this.Name;
		}

		public override int GetHashCode()
		{
			return this.Schema.GetHashCode() ^ this.Name.GetHashCode();
		}

		public static bool operator ==(Table tab1, Table tab2)
		{
			if (object.ReferenceEquals(tab1, tab2))
				return true;
			if ((object)tab1 == null || (object)tab2 == null)
				return false;
			return tab1.Equals(tab2);
		}

		public static bool operator !=(Table tab1, Table tab2)
		{
			return !(tab1==tab2);
		}

	}
}
