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

io.vertx.ext.mail.DKIMSignOptionsConverter Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR3
Show newest version
package io.vertx.ext.mail;

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;
import java.util.Base64;

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


  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, DKIMSignOptions obj) {
    for (java.util.Map.Entry member : json) {
      switch (member.getKey()) {
        case "auid":
          if (member.getValue() instanceof String) {
            obj.setAuid((String)member.getValue());
          }
          break;
        case "bodyCanonAlgo":
          if (member.getValue() instanceof String) {
            obj.setBodyCanonAlgo(io.vertx.ext.mail.CanonicalizationAlgorithm.valueOf((String)member.getValue()));
          }
          break;
        case "bodyLimit":
          if (member.getValue() instanceof Number) {
            obj.setBodyLimit(((Number)member.getValue()).intValue());
          }
          break;
        case "copiedHeaders":
          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.setCopiedHeaders(list);
          }
          break;
        case "expireTime":
          if (member.getValue() instanceof Number) {
            obj.setExpireTime(((Number)member.getValue()).longValue());
          }
          break;
        case "headerCanonAlgo":
          if (member.getValue() instanceof String) {
            obj.setHeaderCanonAlgo(io.vertx.ext.mail.CanonicalizationAlgorithm.valueOf((String)member.getValue()));
          }
          break;
        case "privateKey":
          if (member.getValue() instanceof String) {
            obj.setPrivateKey((String)member.getValue());
          }
          break;
        case "privateKeyPath":
          if (member.getValue() instanceof String) {
            obj.setPrivateKeyPath((String)member.getValue());
          }
          break;
        case "sdid":
          if (member.getValue() instanceof String) {
            obj.setSdid((String)member.getValue());
          }
          break;
        case "selector":
          if (member.getValue() instanceof String) {
            obj.setSelector((String)member.getValue());
          }
          break;
        case "signAlgo":
          if (member.getValue() instanceof String) {
            obj.setSignAlgo(io.vertx.ext.mail.DKIMSignAlgorithm.valueOf((String)member.getValue()));
          }
          break;
        case "signatureTimestamp":
          if (member.getValue() instanceof Boolean) {
            obj.setSignatureTimestamp((Boolean)member.getValue());
          }
          break;
        case "signedHeaders":
          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.setSignedHeaders(list);
          }
          break;
      }
    }
  }

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

  public static void toJson(DKIMSignOptions obj, java.util.Map json) {
    if (obj.getAuid() != null) {
      json.put("auid", obj.getAuid());
    }
    if (obj.getBodyCanonAlgo() != null) {
      json.put("bodyCanonAlgo", obj.getBodyCanonAlgo().name());
    }
    json.put("bodyLimit", obj.getBodyLimit());
    if (obj.getCopiedHeaders() != null) {
      JsonArray array = new JsonArray();
      obj.getCopiedHeaders().forEach(item -> array.add(item));
      json.put("copiedHeaders", array);
    }
    json.put("expireTime", obj.getExpireTime());
    if (obj.getHeaderCanonAlgo() != null) {
      json.put("headerCanonAlgo", obj.getHeaderCanonAlgo().name());
    }
    if (obj.getPrivateKey() != null) {
      json.put("privateKey", obj.getPrivateKey());
    }
    if (obj.getPrivateKeyPath() != null) {
      json.put("privateKeyPath", obj.getPrivateKeyPath());
    }
    if (obj.getSdid() != null) {
      json.put("sdid", obj.getSdid());
    }
    if (obj.getSelector() != null) {
      json.put("selector", obj.getSelector());
    }
    if (obj.getSignAlgo() != null) {
      json.put("signAlgo", obj.getSignAlgo().name());
    }
    json.put("signatureTimestamp", obj.isSignatureTimestamp());
    if (obj.getSignedHeaders() != null) {
      JsonArray array = new JsonArray();
      obj.getSignedHeaders().forEach(item -> array.add(item));
      json.put("signedHeaders", array);
    }
  }
}