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

com.arangodb.shaded.vertx.ext.auth.authentication.TokenCredentialsConverter Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
package com.arangodb.shaded.vertx.ext.auth.authentication;

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.ext.auth.authentication.TokenCredentials}.
 * NOTE: This class has been automatically generated from the {@link com.arangodb.shaded.vertx.ext.auth.authentication.TokenCredentials} original class using Vert.x codegen.
 */
public class TokenCredentialsConverter {


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

   static void fromJson(Iterable> json, TokenCredentials obj) {
    for (java.util.Map.Entry member : json) {
      switch (member.getKey()) {
        case "scopes":
          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.setScopes(list);
          }
          break;
        case "token":
          if (member.getValue() instanceof String) {
            obj.setToken((String)member.getValue());
          }
          break;
      }
    }
  }

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

   static void toJson(TokenCredentials obj, java.util.Map json) {
    if (obj.getScopes() != null) {
      JsonArray array = new JsonArray();
      obj.getScopes().forEach(item -> array.add(item));
      json.put("scopes", array);
    }
    if (obj.getToken() != null) {
      json.put("token", obj.getToken());
    }
  }
}