本文整理汇总了Java中io.vertx.core.json.JsonObject.copy方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.copy方法的具体用法?Java JsonObject.copy怎么用?Java JsonObject.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.copy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: append
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
static JsonObject append(
final JsonObject target,
final JsonObject source,
final boolean immutable
) {
final JsonObject result = immutable ? target.copy() : target;
Observable.fromIterable(source.fieldNames())
.filter(key -> !target.containsKey(key))
.subscribe(key -> result.put(key, source.getValue(key)));
return result;
}
示例2: deNull
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
static JsonObject deNull(
final JsonObject entity,
final boolean immutable) {
final JsonObject result = immutable ? entity.copy() : entity;
final Set<String> keys = entity.fieldNames()
.stream()
.filter(field -> Objects.isNull(entity.getValue(field)))
.collect(Collectors.toSet());
Observable.fromIterable(keys)
.subscribe(result::remove);
return result;
}
示例3: remove
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
static JsonObject remove(
final JsonObject entity,
final boolean immutable,
final String... keys
) {
final JsonObject result = immutable ? entity.copy() : entity;
Observable.fromArray(keys)
.filter(StringUtil::notNil)
.map(result::remove)
.subscribe();
return result;
}
示例4: copy
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
static JsonObject copy(
final JsonObject entity,
final String from,
final String to,
final boolean immutable
) {
final JsonObject result = immutable ? entity.copy() : entity;
if (StringUtil.notNil(to) && entity.containsKey(from)) {
result.put(to, entity.getValue(from));
}
return result;
}
示例5: convert
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static <I, O> JsonObject convert(
final JsonObject entity,
final String field,
final Function<I, O> function,
final boolean immutable
) {
final JsonObject result = immutable ? entity.copy() : entity;
final Object value = result.getValue(field);
if (null != value) {
final I input = (I) value;
result.put(field, function.apply(input));
}
return result;
}
示例6: putAll
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* Creates a new json object containing the content of the given json object merged with
* the given Map. The content of the Map overrides the content of the given json object.
*
* @param conf the configuration
* @param props the map
* @return the json object
*/
private static JsonObject putAll(JsonObject conf, Map<String, String> props) {
Objects.requireNonNull(conf);
Objects.requireNonNull(props);
JsonObject json = conf.copy();
props.entrySet().stream().forEach(entry -> put(json, entry.getKey(), entry.getValue()));
return json;
}