1 /* 2 * hunt-amqp: AMQP library for D programming language, based on hunt-net. 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 module hunt.amqp.ProtonLinkOptions; 12 13 //import io.vertx.codegen.annotations.DataObject; 14 //import io.vertx.core.json.JsonObject; 15 import hunt.amqp.generated.ProtonLinkOptionsConverter; 16 import hunt.Boolean; 17 import hunt.String; 18 import std.json; 19 import hunt.collection.Map; 20 import hunt.collection.LinkedHashMap; 21 import std.variant; 22 /** 23 * Options for configuring link attributes. 24 */ 25 //@DataObject(generateConverter = true, publicConverter = false) 26 27 class ProtonLinkOptions { 28 29 private string linkName; 30 private bool dynamic; 31 32 this() { 33 } 34 35 /** 36 * Create options from JSON 37 * 38 * @param json the JSON 39 */ 40 this(JSONValue json) { 41 Map!(string, Variant) mp = new LinkedHashMap!(string,Variant)(); 42 foreach (string key, value; json) 43 { 44 Variant tmp = value; 45 mp.put(key,tmp); 46 } 47 ProtonLinkOptionsConverter.fromJson(mp, this); 48 } 49 50 /** 51 * Convert to JSON 52 * 53 * @return the JSON 54 */ 55 public JSONValue toJson() { 56 JSONValue json ; 57 ProtonLinkOptionsConverter.toJson(this, json); 58 return json; 59 } 60 61 public ProtonLinkOptions setLinkName(string linkName) { 62 this.linkName = linkName; 63 return this; 64 } 65 66 public string getLinkName() { 67 return linkName; 68 } 69 70 /** 71 * Sets whether the link remote terminus to be used should indicate it is 72 * 'dynamic', requesting the peer names it with a dynamic address. 73 * The address provided by the peer can then be inspected using 74 * {@link ProtonLink#getRemoteAddress()} (or inspecting the remote 75 * terminus details directly) after the link has remotely opened. 76 * 77 * @param dynamic true if the link should request a dynamic terminus address 78 * @return the options 79 */ 80 public ProtonLinkOptions setDynamic(bool dynamic) { 81 this.dynamic = dynamic; 82 return this; 83 } 84 85 public bool isDynamic() { 86 return dynamic; 87 } 88 }