namespace EntKube.SharedKernel.Domain;

/// <summary>
/// Every domain entity in EntKube has a unique identifier. This base class
/// provides that identity and equality comparison so that two entities
/// are considered the same if they share the same Id — regardless of
/// whether their other properties differ.
/// </summary>
public abstract class Entity<TId> where TId : notnull
{
    public TId Id { get; protected set; } = default!;

    public override bool Equals(object? obj)
    {
        if (obj is not Entity<TId> other)
        {
            return false;
        }

        return Id.Equals(other.Id);
    }

    public override int GetHashCode() => Id.GetHashCode();
}
