package io.vertx.amqp;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.impl.JsonUtil;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
public class AmqpReceiverOptionsConverter {
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, AmqpReceiverOptions obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "autoAcknowledgement":
if (member.getValue() instanceof Boolean) {
obj.setAutoAcknowledgement((Boolean)member.getValue());
}
break;
case "capabilities":
if (member.getValue() instanceof JsonArray) {
java.util.ArrayList<java.lang.String> list = new java.util.ArrayList<>();
((Iterable<Object>)member.getValue()).forEach( item -> {
if (item instanceof String)
list.add((String)item);
});
obj.setCapabilities(list);
}
break;
case "capabilitys":
if (member.getValue() instanceof JsonArray) {
((Iterable<Object>)member.getValue()).forEach( item -> {
if (item instanceof String)
obj.addCapability((String)item);
});
}
break;
case "durable":
if (member.getValue() instanceof Boolean) {
obj.setDurable((Boolean)member.getValue());
}
break;
case "dynamic":
if (member.getValue() instanceof Boolean) {
obj.setDynamic((Boolean)member.getValue());
}
break;
case "linkName":
if (member.getValue() instanceof String) {
obj.setLinkName((String)member.getValue());
}
break;
case "maxBufferedMessages":
if (member.getValue() instanceof Number) {
obj.setMaxBufferedMessages(((Number)member.getValue()).intValue());
}
break;
case "qos":
if (member.getValue() instanceof String) {
obj.setQos((String)member.getValue());
}
break;
}
}
}
public static void toJson(AmqpReceiverOptions obj, JsonObject json) {
toJson(obj, json.getMap());
}
public static void toJson(AmqpReceiverOptions obj, java.util.Map<String, Object> json) {
json.put("autoAcknowledgement", obj.isAutoAcknowledgement());
if (obj.getCapabilities() != null) {
JsonArray array = new JsonArray();
obj.getCapabilities().forEach(item -> array.add(item));
json.put("capabilities", array);
}
json.put("durable", obj.isDurable());
json.put("dynamic", obj.isDynamic());
if (obj.getLinkName() != null) {
json.put("linkName", obj.getLinkName());
}
json.put("maxBufferedMessages", obj.getMaxBufferedMessages());
if (obj.getQos() != null) {
json.put("qos", obj.getQos());
}
}
}