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

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

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.DcCoordinates}.
 * NOTE: This class has been automatically generated from the {@link io.vertx.ext.consul.DcCoordinates} original class using Vert.x codegen.
 */
public class DcCoordinatesConverter {

   static void fromJson(Iterable> json, DcCoordinates obj) {
    for (java.util.Map.Entry member : json) {
      switch (member.getKey()) {
        case "datacenter":
          if (member.getValue() instanceof String) {
            obj.setDatacenter((String)member.getValue());
          }
          break;
        case "servers":
          if (member.getValue() instanceof JsonArray) {
            java.util.ArrayList list =  new java.util.ArrayList<>();
            ((Iterable)member.getValue()).forEach( item -> {
              if (item instanceof JsonObject)
                list.add(new io.vertx.ext.consul.Coordinate((io.vertx.core.json.JsonObject)item));
            });
            obj.setServers(list);
          }
          break;
      }
    }
  }

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

   static void toJson(DcCoordinates obj, java.util.Map json) {
    if (obj.getDatacenter() != null) {
      json.put("datacenter", obj.getDatacenter());
    }
    if (obj.getServers() != null) {
      JsonArray array = new JsonArray();
      obj.getServers().forEach(item -> array.add(item.toJson()));
      json.put("servers", array);
    }
  }
}