IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ModuleProvides.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Immutable;
3using System.Linq;
4
6
8{
9
10
14 internal readonly struct ModuleProvides : IComparable<ModuleProvides>
15 {
16
17 readonly string _service;
18 readonly ImmutableArray<string> _providers;
19
25 public ModuleProvides(string service, ImmutableArray<string> providers)
26 {
27 _service = service ?? throw new ArgumentNullException(nameof(service));
28 _providers = providers;
29 }
30
34 public string Service => _service;
35
39 public ImmutableArray<string> Providers => _providers;
40
42 public int CompareTo(ModuleProvides other)
43 {
44 // service
45 int c = _service.CompareTo(other._service);
46 if (c != 0)
47 return c;
48
49 // targets
51 }
52
54 public override bool Equals(object? obj)
55 {
56 return obj is ModuleProvides other && Equals(other);
57 }
58
60 public bool Equals(ModuleProvides other)
61 {
62 return _service == other._service && _providers.SequenceEqual(other._providers);
63 }
64
66 public override int GetHashCode()
67 {
68 var hc = new HashCode();
69 hc.Add(_service);
70
71 foreach (var t in _providers)
72 hc.Add(t);
73
74 return hc.ToHashCode();
75 }
76
77 }
78
79}
Implements an IComparer<T> which lexicographically compares a two lists.
static new readonly LexicographicListComparer< T > Default
Returns a default LexicographicListComparer<T> instance.