// Copyright (C) 2003 Daisuke Arai <darai@users.sourceforge.jp>
// 
// This program is part of Protra.
//
// Protra 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/>.
// 
// $Id: FavoriteBrandItem.cs 263 2010-01-16 13:12:35Z panacoran $

using System;
using Protra.Lib.Db;

namespace Protra
{
	/// <summary>
	/// お気に入り銘柄のListBoxのアイテムです。
	/// </summary>
	public class FavoriteBrandItem
	{
		/// <summary>
		/// 銘柄
		/// </summary>
		private Brand brand;

		/// <summary>
		/// コンストラクタ
		/// </summary>
		/// <param name="brand">銘柄</param>
		public FavoriteBrandItem(Brand brand)
		{
			this.brand = brand;
		}

		/// <summary>
		/// 銘柄を取得します。
		/// </summary>
		public Brand Brand
		{
			get { return brand; }
		}

		/// <summary>
		/// 等価比較を行います。
		/// </summary>
		/// <param name="o">オブジェクト</param>
		/// <returns>比較結果です。</returns>
		public override bool Equals(object o)
		{
			if(o is FavoriteBrandItem)
			{
				FavoriteBrandItem obj = (FavoriteBrandItem)o;
				return brand.Id == obj.brand.Id;
			}

			return false;
		}

		/// <summary>
		/// ハッシュ値を計算します。
		/// </summary>
		/// <returns>ハッシュ値です。</returns>
		public override int GetHashCode()
		{
			return brand.GetHashCode();
		}

		/// <summary>
		/// 文字列表現を求めます。
		/// </summary>
		/// <returns>文字列表現です。</returns>
		public override string ToString()
		{
			return brand.Code + " " + brand.Market.Name + " " + brand.Name;
		}
	}
}
