aboutsummaryrefslogtreecommitdiff
path: root/src/Spv.Generator/DeterministicStringKey.cs
blob: cab4dbcc246acd365cb3f0cad9fa4f1b8033c3f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Diagnostics.CodeAnalysis;

namespace Spv.Generator
{
    internal class DeterministicStringKey : IEquatable<DeterministicStringKey>
    {
        private readonly string _value;

        public DeterministicStringKey(string value)
        {
            _value = value;
        }

        public override int GetHashCode()
        {
            return DeterministicHashCode.GetHashCode(_value);
        }

        public bool Equals(DeterministicStringKey other)
        {
            return _value == other._value;
        }

        public override bool Equals([NotNullWhen(true)] object obj)
        {
            return obj is DeterministicStringKey && Equals((DeterministicStringKey)obj);
        }
    }
}