1 /* 2 * hunt-proton: AMQP Protocol library for D programming language. 3 * 4 * Copyright (C) 2018-2019 HuntLabs 5 * 6 * Website: https://www.huntlabs.net/ 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.proton.amqp.UnknownDescribedType; 13 14 15 import hunt.proton.amqp.DescribedType; 16 17 class UnknownDescribedType : DescribedType 18 { 19 private Object _descriptor; 20 private Object _described; 21 22 this(Object descriptor, Object described) 23 { 24 _descriptor = descriptor; 25 _described = described; 26 } 27 28 override 29 public Object getDescriptor() 30 { 31 return _descriptor; 32 } 33 34 override 35 public Object getDescribed() 36 { 37 return _described; 38 } 39 40 override bool opEquals(Object o) 41 { 42 if (this is o) 43 { 44 return true; 45 } 46 if (o is null || cast(UnknownDescribedType)o is null) 47 { 48 return false; 49 } 50 51 UnknownDescribedType that = cast(UnknownDescribedType)o; 52 53 if (_described !is null ? _described != (that.getDescribed()) : that.getDescribed() !is null) 54 { 55 return false; 56 } 57 if (_descriptor !is null ? _descriptor != (that.getDescriptor()) : that.getDescriptor() !is null) 58 { 59 return false; 60 } 61 62 return true; 63 } 64 65 override 66 public size_t toHash() @trusted nothrow 67 { 68 int result = _descriptor !is null ? cast(int)_descriptor.hashOf : 0; 69 result = 31 * result + (_described !is null ? cast(int)_described.hashOf : 0); 70 return cast(size_t)result; 71 } 72 // 73 //override 74 //public String toString() 75 //{ 76 // return "UnknownDescribedType{" ~ 77 // "descriptor=" ~ _descriptor + 78 // ", described=" ~ _described + 79 // '}'; 80 //} 81 }