1 //
2 // Copyright (c) 2010-2018 Antmicro
3 //
4 // This file is licensed under the MIT License.
5 // Full license text is available in 'licenses/MIT.txt'.
6 //
7 
8 namespace Antmicro.Renode.PlatformDescription.Syntax
9 {
10     public sealed class IrqEnd
11     {
IrqEnd(string propertyName, int number)12         public IrqEnd(string propertyName, int number)
13         {
14             PropertyName = propertyName;
15             Number = number;
16         }
17 
ToString()18         public override string ToString()
19         {
20             return string.Format("[IrqEnd: {0}]", ToShortString());
21         }
22 
ToShortString()23         public string ToShortString()
24         {
25             return PropertyName ?? Number.ToString();
26         }
27 
Equals(object obj)28         public override bool Equals(object obj)
29         {
30             var other = obj as IrqEnd;
31             if(other == null)
32             {
33                 return false;
34             }
35             return PropertyName == other.PropertyName && Number == other.Number;
36         }
37 
GetHashCode()38         public override int GetHashCode()
39         {
40             return (11 * 19 * (PropertyName ?? "").GetHashCode()) * 19 + Number.GetHashCode();
41         }
42 
43         public string PropertyName { get; private set; }
44         public int Number { get; private set; }
45 
operator ==(IrqEnd a, IrqEnd b)46         public static bool operator ==(IrqEnd a, IrqEnd b)
47         {
48             if((object)a == null)
49             {
50                 return (object)b == null;
51             }
52             return a.Equals(b);
53         }
54 
operator !=(IrqEnd a, IrqEnd b)55         public static bool operator !=(IrqEnd a, IrqEnd b)
56         {
57             return !(a == b);
58         }
59     }
60 
61     // the class is there because we are not able to have position aware IEnumerable
62 }
63