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.codec.impl.DescribedTypeImpl; 13 14 import hunt.proton.amqp.DescribedType; 15 16 class DescribedTypeImpl : DescribedType 17 { 18 private Object _descriptor; 19 private Object _described; 20 21 this(Object descriptor, Object described) 22 { 23 _descriptor = descriptor; 24 _described = described; 25 } 26 27 override 28 public Object getDescriptor() 29 { 30 return _descriptor; 31 } 32 33 override 34 public Object getDescribed() 35 { 36 return _described; 37 } 38 39 override bool opEquals(Object o) { 40 { 41 if (this is o) 42 { 43 return true; 44 } 45 if (o is null || cast(DescribedTypeImpl)o is null) 46 { 47 return false; 48 } 49 50 DescribedType that = cast(DescribedType) o; 51 52 if (_described !is null ? _described != ( that.getDescribed()) : that.getDescribed() !is null) 53 { 54 return false; 55 } 56 if (_descriptor !is null ? _descriptor !=( that.getDescriptor()) : that.getDescriptor() !is null) 57 { 58 return false; 59 } 60 61 return true; 62 } 63 64 //override 65 //public int hashCode() 66 //{ 67 // int result = _descriptor != null ? _descriptor.hashCode() : 0; 68 // result = 31 * result + (_described != null ? _described.hashCode() : 0); 69 // return result; 70 //} 71 // 72 //override 73 //public String toString() 74 //{ 75 // return "{" + _descriptor + 76 // ": " ~ _described + 77 // '}'; 78 //} 79 } 80 }