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.transport.Detach;
13 
14 import hunt.proton.amqp.Binary;
15 import hunt.proton.amqp.UnsignedInteger;
16 import hunt.proton.amqp.transport.FrameBody;
17 import hunt.proton.amqp.transport.ErrorCondition;
18 import hunt.logging;
19 import hunt.Boolean;
20 
21 class Detach : FrameBody {
22     private UnsignedInteger _handle;
23     private Boolean _closed;
24     private ErrorCondition _error;
25 
26     this() {
27         _closed = new Boolean(false);
28     }
29 
30     this(Detach other) {
31         this._handle = other.getHandle();
32         this._closed = other.getClosed();
33         if (other._error !is null) {
34             this._error = new ErrorCondition();
35             this._error.copyFrom(other.getError());
36         }
37     }
38 
39     UnsignedInteger getHandle() {
40         return _handle;
41     }
42 
43     void setHandle(UnsignedInteger handle) {
44         if (handle is null) {
45             logError("the handle field is mandatory");
46         }
47 
48         _handle = handle;
49     }
50 
51     Boolean getClosed() {
52         return _closed;
53     }
54 
55     void setClosed(Boolean closed) {
56         _closed = closed;
57     }
58 
59     ErrorCondition getError() {
60         return _error;
61     }
62 
63     void setError(ErrorCondition error) {
64         _error = error;
65     }
66 
67     //override
68     void invoke(E)(FrameBodyHandler!E handler, Binary payload, E context) {
69         handler.handleDetach(this, payload, context);
70     }
71 
72     FrameBody copy() {
73         return new Detach(this);
74     }
75 }