summaryrefslogtreecommitdiff
path: root/src/Notepad/Domain/FileSystem/AbsoluteFilePath.cs
blob: 31ef07baa13ff1359860587305c4f568f8c6f0ea (plain)
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
31
32
33
34
namespace Notepad.Domain.FileSystem {
    public class AbsoluteFilePath : IFilePath {
        private readonly string rawFilePath;

        public AbsoluteFilePath(string rawFilePath) {
            this.rawFilePath = rawFilePath;
        }

        public string RawPathToFile() {
            return rawFilePath;
        }

        public bool Equals(IFilePath other) {
            if (ReferenceEquals(null, other)) {
                return false;
            }
            return ReferenceEquals(this, other) || Equals(other.RawPathToFile(), rawFilePath);
        }

        public override bool Equals(object other) {
            if (ReferenceEquals(null, other)) {
                return false;
            }
            if (ReferenceEquals(this, other)) {
                return true;
            }
            return other.GetType() == typeof (AbsoluteFilePath) && Equals((AbsoluteFilePath) other);
        }

        public override int GetHashCode() {
            return (rawFilePath != null ? rawFilePath.GetHashCode() : 0);
        }
    }
}