Example usage for io.vertx.core.json JsonObject put

List of usage examples for io.vertx.core.json JsonObject put

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject put.

Prototype

public JsonObject put(String key, Object value) 

Source Link

Document

Put an Object into the JSON object with the specified key.

Usage

From source file:com.reachauto.device.LocationConverter.java

License:Apache License

public static void toJson(Location obj, JsonObject json) {
    if (obj.getEle() != null) {
        json.put("ele", obj.getEle());
    }/* w ww  .java2  s. com*/
    if (obj.getLat() != null) {
        json.put("lat", obj.getLat());
    }
    if (obj.getLon() != null) {
        json.put("lon", obj.getLon());
    }
}

From source file:com.reachauto.product.ProductConverter.java

License:Apache License

public static void toJson(Product obj, JsonObject json) {
    if (obj.getAccount() != null) {
        json.put("account", obj.getAccount().toJson());
    }/*from  w  w w. j av a2  s  .c o m*/
    if (obj.getApiKey() != null) {
        json.put("apiKey", obj.getApiKey());
    }
    if (obj.getDelFlag() != null) {
        json.put("delFlag", obj.getDelFlag());
    }
    if (obj.getId() != null) {
        json.put("id", obj.getId());
    }
    if (obj.getName() != null) {
        json.put("name", obj.getName());
    }
}

From source file:com.reachauto.product.ProductServiceVertxEBProxy.java

License:Apache License

public ProductService addProduct(Product product, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*w  ww  .  j  av a 2  s .  c  o  m*/
    JsonObject _json = new JsonObject();
    _json.put("product", product == null ? null : product.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "addProduct");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:com.reachauto.product.ProductServiceVertxEBProxy.java

License:Apache License

public ProductService deleteProduct(Integer id, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from   www . j  a v a2 s  . co  m*/
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "deleteProduct");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:com.reachauto.product.ProductServiceVertxEBProxy.java

License:Apache License

public ProductService updateProduct(Product product, Handler<AsyncResult<Product>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/* w  w w  .  j  a  v  a  2 s  .  co m*/
    JsonObject _json = new JsonObject();
    _json.put("product", product == null ? null : product.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "updateProduct");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future
                    .succeededFuture(res.result().body() == null ? null : new Product(res.result().body())));
        }
    });
    return this;
}

From source file:com.reachauto.product.ProductServiceVertxEBProxy.java

License:Apache License

public ProductService retrieveProduct(Integer id, Handler<AsyncResult<Product>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from w w  w . j  a va2 s . com
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveProduct");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future
                    .succeededFuture(res.result().body() == null ? null : new Product(res.result().body())));
        }
    });
    return this;
}

From source file:com.test.db.DbServiceVertxEBProxy.java

License:Apache License

public void storedProc(String procName, JsonObject databaseConfig,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from   w w w. j a v  a 2s .co m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("procName", procName);
    _json.put("databaseConfig", databaseConfig);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "storedProc");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.test.db.DbServiceVertxEBProxy.java

License:Apache License

public void createStm(String query, JsonObject databaseConfig, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from  w  ww  .j ava2 s.  c om
    }
    JsonObject _json = new JsonObject();
    _json.put("query", query);
    _json.put("databaseConfig", databaseConfig);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createStm");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.test.db.DbServiceVertxEBProxy.java

License:Apache License

public void update(String query, JsonObject databaseConfig, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from  w  ww .ja va 2s  . c  o m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("query", query);
    _json.put("databaseConfig", databaseConfig);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "update");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.test.db.DbServiceVertxEBProxy.java

License:Apache License

public void delete(String query, JsonObject databaseConfig, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from w ww  .j a v a  2  s . c  om
    }
    JsonObject _json = new JsonObject();
    _json.put("query", query);
    _json.put("databaseConfig", databaseConfig);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "delete");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}