IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ModuleOpens.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Immutable;
3using System.Linq;
4
5using IKVM.ByteCode;
7
9{
10
11
15 internal readonly struct ModuleOpens : IComparable<ModuleOpens>
16 {
17
18 readonly ModuleOpensFlag _modifiers;
19 readonly string _source;
20 readonly ImmutableHashSet<string> _targets;
21
28 public ModuleOpens(ModuleOpensFlag modifiers, string source, ImmutableHashSet<string> targets)
29 {
30 _modifiers = modifiers;
31 _source = source ?? throw new ArgumentNullException(nameof(source));
32 _targets = targets ?? throw new ArgumentNullException(nameof(targets));
33 }
34
38 public ModuleOpensFlag Modifiers => _modifiers;
39
43 public string Source => _source;
44
49 public ImmutableHashSet<string> Targets => _targets;
50
52 public int CompareTo(ModuleOpens other)
53 {
54 int c = _source.CompareTo(other._source);
55 if (c != 0)
56 return c;
57
58 // modifiers
59 c = _modifiers.CompareTo(other.Modifiers);
60 if (c != 0)
61 return c;
62
63 // targets
64 var t1 = _targets.ToArray();
65 var t2 = other._targets.ToArray();
66 Array.Sort(t1);
67 Array.Sort(t2);
69 }
70
72 public override bool Equals(object? obj)
73 {
74 return obj is ModuleOpens other && Equals(other);
75 }
76
78 public bool Equals(ModuleOpens other)
79 {
80 return _modifiers == other._modifiers && _source == other._source && _targets.SetEquals(other._targets);
81 }
82
84 public override int GetHashCode()
85 {
86 var hc = new HashCode();
87 hc.Add(_modifiers);
88 hc.Add(_source);
89
90 foreach (var t in _targets)
91 hc.Add(t);
92
93 return hc.ToHashCode();
94 }
95
96 }
97
98}
Implements an IComparer<T> which lexicographically compares a two lists.
static new readonly LexicographicListComparer< T > Default
Returns a default LexicographicListComparer<T> instance.