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.messaging.TerminusDurability;
14 
15 import hunt.proton.amqp.UnsignedInteger;
16 
17 class TerminusDurability
18 {
19     //enum{
20     //    NONE = 0,
21     //    CONFIGURATION,
22     //    UNSETTLED_STATE
23     //}
24     //
25 
26     private int _val;
27 
28     this(int value)
29     {
30         _val = value;
31     }
32 
33      shared static  this() {
34          NONE = new TerminusDurability(0);
35          CONFIGURATION = new TerminusDurability(1);
36          UNSETTLED_STATE = new TerminusDurability(2);
37      }
38 
39     __gshared TerminusDurability NONE ;
40     __gshared TerminusDurability CONFIGURATION ;
41     __gshared TerminusDurability UNSETTLED_STATE;
42     //__gshared TerminusExpiryPolicy CONNECTION_CLOSE ;
43     //__gshared TerminusExpiryPolicy NEVER ;
44 
45     public UnsignedInteger getValue()
46     {
47         return UnsignedInteger.valueOf(ordinal());
48     }
49 
50     public int ordinal()
51     {
52         return _val;
53     }
54 
55     public static TerminusDurability get(UnsignedInteger value)
56     {
57         switch (value.intValue())
58         {
59             case 0:
60                 return NONE;
61             case 1:
62                 return CONFIGURATION;
63             case 2:
64                 return UNSETTLED_STATE;
65             default:
66                 return null;
67         }
68     }
69 
70 }