All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.ext.consul.NodeConverter Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR5
Show newest version
package io.vertx.ext.consul;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.time.Instant;
import java.time.format.DateTimeFormatter;

/**
 * Converter and mapper for {@link io.vertx.ext.consul.Node}.
 * NOTE: This class has been automatically generated from the {@link io.vertx.ext.consul.Node} original class using Vert.x codegen.
 */
public class NodeConverter {

   static void fromJson(Iterable> json, Node obj) {
    for (java.util.Map.Entry member : json) {
      switch (member.getKey()) {
        case "id":
          if (member.getValue() instanceof String) {
            obj.setId((String)member.getValue());
          }
          break;
        case "name":
          if (member.getValue() instanceof String) {
            obj.setName((String)member.getValue());
          }
          break;
        case "address":
          if (member.getValue() instanceof String) {
            obj.setAddress((String)member.getValue());
          }
          break;
        case "lanAddress":
          if (member.getValue() instanceof String) {
            obj.setLanAddress((String)member.getValue());
          }
          break;
        case "wanAddress":
          if (member.getValue() instanceof String) {
            obj.setWanAddress((String)member.getValue());
          }
          break;
        case "datacenter":
          if (member.getValue() instanceof String) {
            obj.setDatacenter((String)member.getValue());
          }
          break;
        case "nodeMeta":
          if (member.getValue() instanceof JsonObject) {
            java.util.Map map = new java.util.LinkedHashMap<>();
            ((Iterable>)member.getValue()).forEach(entry -> {
              if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String)entry.getValue());
            });
            obj.setNodeMeta(map);
          }
          break;
      }
    }
  }

   static void toJson(Node obj, JsonObject json) {
    toJson(obj, json.getMap());
  }

   static void toJson(Node obj, java.util.Map json) {
    if (obj.getId() != null) {
      json.put("id", obj.getId());
    }
    if (obj.getName() != null) {
      json.put("name", obj.getName());
    }
    if (obj.getAddress() != null) {
      json.put("address", obj.getAddress());
    }
    if (obj.getLanAddress() != null) {
      json.put("lanAddress", obj.getLanAddress());
    }
    if (obj.getWanAddress() != null) {
      json.put("wanAddress", obj.getWanAddress());
    }
    if (obj.getDatacenter() != null) {
      json.put("datacenter", obj.getDatacenter());
    }
    if (obj.getNodeMeta() != null) {
      JsonObject map = new JsonObject();
      obj.getNodeMeta().forEach((key, value) -> map.put(key, value));
      json.put("nodeMeta", map);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy