IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ModuleRequires.cs
Go to the documentation of this file.
1using System;
2
3using IKVM.ByteCode;
4
6{
7
11 internal readonly struct ModuleRequires : IComparable<ModuleRequires>
12 {
13
14 readonly ModuleRequiresFlag _modifiers;
15 readonly string _name;
16 readonly ModuleVersion _version;
17
24 public ModuleRequires(ModuleRequiresFlag modifiers, string name, ModuleVersion version)
25 {
26 _modifiers = modifiers;
27 _name = name ?? throw new ArgumentNullException(nameof(name));
28 _version = version;
29 }
30
34 public readonly ModuleRequiresFlag Modifiers => _modifiers;
35
39 public readonly string Name => _name;
40
44 public readonly ModuleVersion Version => _version;
45
47 public readonly int CompareTo(ModuleRequires other)
48 {
49 int c = _name.CompareTo(other._name);
50 if (c != 0)
51 return c;
52
53 // version
54 c = _version.CompareTo(other._version);
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 return 0;
64 }
65
67 public readonly override bool Equals(object? obj)
68 {
69 return obj is ModuleRequires other && Equals(other);
70 }
71
73 public readonly bool Equals(ModuleRequires other)
74 {
75 return _modifiers == other._modifiers && _name == other._name && _version == other._version;
76 }
77
79 public readonly override int GetHashCode()
80 {
81 var hc = new HashCode();
82 hc.Add(_modifiers);
83 hc.Add(_name);
84 if (_version.IsValid)
85 hc.Add(_version);
86
87 return hc.ToHashCode();
88 }
89
90 }
91
92}
global::java.lang.invoke.LambdaForm.Name Name