using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PasteApeart.Domain.Entity
{
/// <summary>
///
/// </summary>
public abstract class Entity
{
}
/// <summary>
///
/// </summary>
/// <typeparam name="TKey"></typeparam>
public abstract class Entity<TKey> : IEntity
{
/// <summary>
///
/// </summary>
public virtual TKey Id { get; set; }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object obj)
{
if (obj is not Entity<TKey> other)
return false;
if (ReferenceEquals(this, other))
return true;
if (Id == null || other.Id == null)
return false;
return Id.Equals(other.Id);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Id?.GetHashCode() ?? 0;
}
/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator ==(Entity<TKey> left, Entity<TKey> right)
{
return Equals(left, right);
}
/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator !=(Entity<TKey> left, Entity<TKey> right)
{
return !Equals(left, right);
}
}
}