本文整理了Java中io.vertx.ext.consul.KeyValue.<init>()
方法的一些代码示例,展示了KeyValue.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyValue.<init>()
方法的具体详情如下:
包路径:io.vertx.ext.consul.KeyValue
类名称: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());
}
内容来源于网络,如有侵权,请联系作者删除!