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 13 module hunt.proton.amqp.transport.ErrorCondition; 14 15 16 import hunt.proton.amqp.Symbol; 17 import hunt.logging; 18 import hunt.Object; 19 import hunt.String; 20 21 class ErrorCondition 22 { 23 private Symbol _condition; 24 private String _description; 25 private IObject _info; 26 27 this() 28 { 29 } 30 31 this(Symbol condition, String description) 32 { 33 _condition = condition; 34 _description = description; 35 } 36 37 public Symbol getCondition() 38 { 39 return _condition; 40 } 41 42 public void setCondition(Symbol condition) 43 { 44 if( condition is null ) 45 { 46 logError("the condition field is mandatory"); 47 } 48 49 _condition = condition; 50 } 51 52 public String getDescription() 53 { 54 return _description; 55 } 56 57 public void setDescription(String description) 58 { 59 _description = description; 60 } 61 62 public IObject getInfo() 63 { 64 return _info; 65 } 66 67 public void setInfo(IObject info) 68 { 69 _info = info; 70 } 71 72 public void clear() 73 { 74 _condition = null; 75 _description = null; 76 _info = null; 77 } 78 79 public void copyFrom(ErrorCondition condition) 80 { 81 _condition = condition._condition; 82 _description = condition._description; 83 _info = condition._info; 84 } 85 86 public int hashCode() 87 { 88 int result = _condition !is null ? _condition.hashCode() : 0; 89 result = 31 * result + (_description !is null ? cast(int)(((cast(string)(_description.getBytes())).hashOf)) : 0); 90 result = 31 * result + (_info !is null ? cast(int) _info.toHash() : 0); 91 return result; 92 } 93 94 override bool opEquals(Object o) 95 { 96 if (this is o) 97 { 98 return true; 99 } 100 if (o is null || cast(ErrorCondition)o is null) 101 { 102 return false; 103 } 104 105 ErrorCondition that = cast(ErrorCondition)o; 106 107 if (_condition !is null ? _condition != (that.getCondition()) : that.getCondition() !is null) 108 { 109 return false; 110 } 111 if (_description !is null ? _description != (that.getDescription()) : that.getDescription() !is null) 112 { 113 return false; 114 } 115 if (_info !is null ? _info != (that.getInfo()) : that.getInfo() !is null) 116 { 117 return false; 118 } 119 120 return true; 121 } 122 123 }