io.vertx.ext.consul.KeyValue.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中io.vertx.ext.consul.KeyValue.<init>()方法的一些代码示例,展示了KeyValue.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyValue.<init>()方法的具体详情如下:
包路径:io.vertx.ext.consul.KeyValue
类名称:KeyValue
方法名:<init>

KeyValue.<init>介绍

[英]Default constructor
[中]默认构造函数

代码示例

代码示例来源:origin: io.vertx/vertx-consul-client

public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, KeyValueList obj) {
 for (java.util.Map.Entry<String, Object> member : json) {
  switch (member.getKey()) {
   case "index":
    if (member.getValue() instanceof Number) {
     obj.setIndex(((Number)member.getValue()).longValue());
    }
    break;
   case "list":
    if (member.getValue() instanceof JsonArray) {
     java.util.ArrayList<io.vertx.ext.consul.KeyValue> list =  new java.util.ArrayList<>();
     ((Iterable<Object>)member.getValue()).forEach( item -> {
      if (item instanceof JsonObject)
       list.add(new io.vertx.ext.consul.KeyValue((JsonObject)item));
     });
     obj.setList(list);
    }
    break;
  }
 }
}

代码示例来源:origin: io.vertx/vertx-consul-client

static KeyValue parse(JsonObject json) {
  return new KeyValue()
   .setKey(json.getString(KEY_KEY))
   .setValue(Utils.decode64(json.getString(VALUE_KEY)))
   .setSession(json.getString(SESSION_KEY))
   .setFlags(json.getLong(FLAGS_KEY, 0L))
   .setCreateIndex(json.getLong(CREATE_KEY, 0L))
   .setModifyIndex(json.getLong(MODIFY_KEY, 0L))
   .setLockIndex(json.getLong(LOCK_KEY, 0L));
 }
}

代码示例来源:origin: io.vertx/vertx-consul-client

@Override
public ConsulClient getValueWithOptions(String key, BlockingQueryOptions options, Handler<AsyncResult<KeyValue>> resultHandler) {
 request(KV_VALID_CODES, HttpMethod.GET, "/v1/kv/" + urlEncode(key), new Query().put(options), null, resultHandler, resp -> {
  if (resp.statusCode() == HttpResponseStatus.NOT_FOUND.code()) {
   return new KeyValue();
  } else {
   return KVParser.parse(resp.bodyAsJsonArray().getJsonObject(0));
  }
 });
 return this;
}

代码示例来源:origin: io.vertx/vertx-consul-client

@Test
public void testKeyValueCopy() {
 KeyValue kv = randomKeyValue();
 checkKeyValue(kv, new KeyValue(kv));
 checkKeyValue(kv, new KeyValue(kv.toJson()));
}

代码示例来源:origin: io.vertx/vertx-consul-client

/**
 * Constructor from JSON
 *
 * @param json the JSON
 */
public TxnResponse(JsonObject json) {
 if (json.getValue("Results") instanceof JsonArray) {
  json.getJsonArray("Results").forEach(entry -> {
   JsonObject obj = (JsonObject) entry;
   if (obj.containsKey("KV")) {
    results.add(new KeyValue(obj.getJsonObject("KV")));
   }
  });
 }
 if (json.getValue("Errors") instanceof JsonArray) {
  json.getJsonArray("Errors").forEach(entry -> errors.add(new TxnError((JsonObject) entry)));
 }
}

代码示例来源:origin: io.vertx/vertx-consul-client

public static KeyValue randomKeyValue() {
 return new KeyValue()
  .setKey(randomAlphaString(10))
  .setValue(randomAlphaString(10))
  .setSession(randomAlphaString(10))
  .setCreateIndex(randomLong())
  .setFlags(randomLong())
  .setModifyIndex(randomLong())
  .setLockIndex(randomLong());
}

相关文章