using System;

namespace Territorium
{
    public struct Identifier
    {
        public bool Equals(Identifier other) => Value.Equals(other.Value);

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            return obj is Identifier && Equals((Identifier)obj);
        }

        public override int GetHashCode() => Value.GetHashCode();

        public Guid Value { get; }

        public Identifier(Guid value) => Value = value;

        public static implicit operator Identifier(Guid identifier) => new Identifier(identifier);

        public static implicit operator Guid(Identifier identifier) => identifier.Value;

        public static bool operator ==(Identifier identifier, Identifier other) =>
            identifier.Equals(other.Value);

        public static bool operator !=(Identifier identifier, Identifier other) => !identifier
            .Equals(other.Value);
    }
}