1 module hunt.amqp.generated.ProtonClientOptionsConverter;
2 
3 //import io.vertx.core.json.JsonObject;
4 //import io.vertx.core.json.JsonArray;
5 //import java.time.Instant;
6 //import java.time.format.DateTimeFormatter;
7 import hunt.String;
8 import hunt.collection.Map;
9 import std.json;
10 import hunt.amqp.ProtonClientOptions;
11 import hunt.Number;
12 import hunt.collection.LinkedHashMap;
13 import std.variant;
14 /**
15  * Converter and mapper for {@link io.vertx.proton.ProtonClientOptions}.
16  * NOTE: This class has been automatically generated from the {@link io.vertx.proton.ProtonClientOptions} original class using Vert.x codegen.
17  */
18 class ProtonClientOptionsConverter {
19 
20     //foreach (size_t index, value; jv)
21     //{
22     //    static assert(is(typeof(value) == JSONValue));
23     //    assert(value.type == JSONType.integer);
24     //    assertNotThrown(value.integer);
25     //    assert(index == (value.integer-3));
26     //}
27  //*b.peek!(int)
28    static void fromJson(Map!(string, Variant) json, ProtonClientOptions obj) {
29     foreach (MapEntry!(string, Variant) member ; json) {
30       switch (member.getKey()) {
31         case "enabledSaslMechanisms":
32           JSONValue js = *(member.getValue()).peek!JSONValue;
33           if (js.type() == JSONType.array) {
34             foreach (size_t index, value; js)
35             {
36                 string t = (value.str);
37                 obj.addEnabledSaslMechanism(t);
38             }
39             //((Iterable<Object>)member.getValue()).forEach( item -> {
40             //  if (item instanceof String)
41             //    obj.addEnabledSaslMechanism((String)item);
42             //});
43           }
44           break;
45         case "heartbeat":
46           JSONValue js = *(member.getValue()).peek!JSONValue;
47           //int num = *(member.getValue()).peek!int;
48           //if (js !is null) {
49             obj.setHeartbeat(cast(int)js.integer);
50           //}
51           break;
52         case "maxFrameSize":
53             JSONValue js = *(member.getValue()).peek!JSONValue;
54           // int num = *(member.getValue()).peek!int;
55          // if (js !is null) {
56             obj.setMaxFrameSize(cast(int)js.integer);
57           //}
58           break;
59         case "sniServerName":
60           JSONValue js = *(member.getValue()).peek!JSONValue;
61           //string str = *(member.getValue()).peek!string;
62          // if (js !is null) {
63             obj.setSniServerName(js.str);
64           //}
65           break;
66         case "virtualHost":
67          JSONValue js = *(member.getValue()).peek!JSONValue;
68          //string str = *(member.getValue()).peek!string;
69           //if (js !is null) {
70             obj.setVirtualHost(js.str);
71           //}
72           break;
73          default:
74           break;
75       }
76     }
77   }
78 
79    static void toJson(ProtonClientOptions obj, JSONValue json) {
80        Map!(string, Variant) mp = new LinkedHashMap!(string,Variant)();
81        foreach (string key, value; json)
82        {
83            Variant tmp = value;
84            mp.put(key,tmp);
85        }
86         toJson(obj, mp);
87   }
88 
89    static void toJson(ProtonClientOptions obj, Map!(string, Variant) json) {
90     if (obj.getEnabledSaslMechanisms() !is null) {
91       string [] arry;
92       foreach(string str ;  obj.getEnabledSaslMechanisms())
93       {
94             arry ~= str;
95       }
96       JSONValue array = JSONValue(arry);
97     //  obj.getEnabledSaslMechanisms().forEach(item -> array.add(item));
98       Variant ar = array;
99       json.put("enabledSaslMechanisms", ar);
100     }
101     Variant hb = obj.getHeartbeat();
102     json.put("heartbeat", hb);
103     Variant mx = obj.getMaxFrameSize();
104     json.put("maxFrameSize", mx);
105     if (obj.getSniServerName().length != 0) {
106       Variant sn =   obj.getSniServerName();
107       json.put("sniServerName", sn);
108     }
109     if (obj.getVirtualHost().length != 0) {
110       Variant vh =   obj.getVirtualHost();
111       json.put("virtualHost", vh);
112     }
113   }
114 }