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

com.arangodb.shaded.vertx.core.http.WebSocketConnectOptionsConverter Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
package com.arangodb.shaded.vertx.core.http;

import com.arangodb.shaded.vertx.core.json.JsonObject;
import com.arangodb.shaded.vertx.core.json.JsonArray;
import com.arangodb.shaded.vertx.core.json.impl.JsonUtil;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Base64;

/**
 * Converter and mapper for {@link com.arangodb.shaded.vertx.core.http.WebSocketConnectOptions}.
 * NOTE: This class has been automatically generated from the {@link com.arangodb.shaded.vertx.core.http.WebSocketConnectOptions} original class using Vert.x codegen.
 */
public class WebSocketConnectOptionsConverter {


  private static final Base64.Decoder BASE64_DECODER = JsonUtil.BASE64_DECODER;
  private static final Base64.Encoder BASE64_ENCODER = JsonUtil.BASE64_ENCODER;

  public static void fromJson(Iterable> json, WebSocketConnectOptions obj) {
    for (java.util.Map.Entry member : json) {
      switch (member.getKey()) {
        case "allowOriginHeader":
          if (member.getValue() instanceof Boolean) {
            obj.setAllowOriginHeader((Boolean)member.getValue());
          }
          break;
        case "registerWriteHandlers":
          if (member.getValue() instanceof Boolean) {
            obj.setRegisterWriteHandlers((Boolean)member.getValue());
          }
          break;
        case "subProtocols":
          if (member.getValue() instanceof JsonArray) {
            java.util.ArrayList list =  new java.util.ArrayList<>();
            ((Iterable)member.getValue()).forEach( item -> {
              if (item instanceof String)
                list.add((String)item);
            });
            obj.setSubProtocols(list);
          }
          break;
        case "version":
          if (member.getValue() instanceof String) {
            obj.setVersion(com.arangodb.shaded.vertx.core.http.WebsocketVersion.valueOf((String)member.getValue()));
          }
          break;
      }
    }
  }

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

  public static void toJson(WebSocketConnectOptions obj, java.util.Map json) {
    json.put("allowOriginHeader", obj.getAllowOriginHeader());
    json.put("registerWriteHandlers", obj.isRegisterWriteHandlers());
    if (obj.getSubProtocols() != null) {
      JsonArray array = new JsonArray();
      obj.getSubProtocols().forEach(item -> array.add(item));
      json.put("subProtocols", array);
    }
    if (obj.getVersion() != null) {
      json.put("version", obj.getVersion().name());
    }
  }
}