using System;
using System.Collections.Generic;

namespace skyscraper5.Skyscraper.Scraper.Storage.Utilities
{
    public class DatabaseKeyT2MI : IEquatable<DatabaseKeyT2MI>
    {
        private readonly int nid;
        private readonly int tsid;
        private readonly int pid;

        public DatabaseKeyT2MI(int nid, int tsid, int pid)
        {
            this.nid = nid;
            this.tsid = tsid;
            this.pid = pid;
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as DatabaseKeyT2MI);
        }

        public bool Equals(DatabaseKeyT2MI other)
        {
            return other is not null &&
                   nid == other.nid &&
                   tsid == other.tsid &&
                   pid == other.pid;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(nid, tsid, pid);
        }

        public static bool operator ==(DatabaseKeyT2MI left, DatabaseKeyT2MI right)
        {
            return EqualityComparer<DatabaseKeyT2MI>.Default.Equals(left, right);
        }

        public static bool operator !=(DatabaseKeyT2MI left, DatabaseKeyT2MI right)
        {
            return !(left == right);
        }
    }
}
