Example usage for io.vertx.core MultiMap isEmpty

List of usage examples for io.vertx.core MultiMap isEmpty

Introduction

In this page you can find the example usage for io.vertx.core MultiMap isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Return true if empty

Usage

From source file:co.runrightfast.core.utils.VertxUtils.java

License:Apache License

static JsonObject toJsonObject(@NonNull final MultiMap map) {
    if (map.isEmpty()) {
        return EMPTY_OBJECT;
    }/*  w w w. j  ava 2s .  com*/

    final JsonObjectBuilder json = Json.createObjectBuilder();
    map.names().stream().forEach(name -> {
        final List<String> values = map.getAll(name);
        if (values.size() == 1) {
            json.add(name, values.get(0));
        } else {
            json.add(name, JsonUtils.toJsonArray(values));
        }
    });
    return json.build();
}