// Path: portfolio-service/src/main/generated/io/vertx/workshop/portfolio/reactivex/PortfolioService.java
// @io.vertx.lang.reactivex.RxGen(io.vertx.workshop.portfolio.PortfolioService.class)
// public class PortfolioService {
// 
//   public static final io.vertx.lang.reactivex.TypeArg<PortfolioService> __TYPE_ARG = new io.vertx.lang.reactivex.TypeArg<>(
//     obj -> new PortfolioService((io.vertx.workshop.portfolio.PortfolioService) obj),
//     PortfolioService::getDelegate
//   );
// 
//   private final io.vertx.workshop.portfolio.PortfolioService delegate;
//   
//   public PortfolioService(io.vertx.workshop.portfolio.PortfolioService delegate) {
//     this.delegate = delegate;
//   }
// 
//   public io.vertx.workshop.portfolio.PortfolioService getDelegate() {
//     return delegate;
//   }
// 
//   /**
//    * Gets the portfolio.
//    * @param resultHandler the result handler called when the portfolio has been retrieved. The async result indicates whether the call was successful or not.
//    */
//   public void getPortfolio(Handler<AsyncResult<Portfolio>> resultHandler) { 
//     delegate.getPortfolio(resultHandler);
//   }
// 
//   /**
//    * Gets the portfolio.
//    * @return 
//    */
//   public Single<Portfolio> rxGetPortfolio() { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Portfolio>(handler -> {
//       getPortfolio(handler);
//     });
//   }
// 
//   /**
//    * Buy `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @param resultHandler the result handler with the updated portfolio. If the action cannot be executed, the async result is market as a failure (not enough money, not enough shares available...)
//    */
//   public void buy(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) { 
//     delegate.buy(amount, quote, resultHandler);
//   }
// 
//   /**
//    * Buy `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @return 
//    */
//   public Single<Portfolio> rxBuy(int amount, JsonObject quote) { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Portfolio>(handler -> {
//       buy(amount, quote, handler);
//     });
//   }
// 
//   /**
//    * Sell `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @param resultHandler the result handler with the updated portfolio. If the action cannot be executed, the async result is market as a failure (not enough share...)
//    */
//   public void sell(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) { 
//     delegate.sell(amount, quote, resultHandler);
//   }
// 
//   /**
//    * Sell `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @return 
//    */
//   public Single<Portfolio> rxSell(int amount, JsonObject quote) { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Portfolio>(handler -> {
//       sell(amount, quote, handler);
//     });
//   }
// 
//   /**
//    * Evaluates the current value of the portfolio.
//    * @param resultHandler the result handler with the valuation
//    */
//   public void evaluate(Handler<AsyncResult<Double>> resultHandler) { 
//     delegate.evaluate(resultHandler);
//   }
// 
//   /**
//    * Evaluates the current value of the portfolio.
//    * @return 
//    */
//   public Single<Double> rxEvaluate() { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Double>(handler -> {
//       evaluate(handler);
//     });
//   }
// 
// 
//   public static  PortfolioService newInstance(io.vertx.workshop.portfolio.PortfolioService arg) {
//     return arg != null ? new PortfolioService(arg) : null;
//   }
// }


import io.reactivex.Single;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.reactivex.core.AbstractVerticle;
import io.vertx.reactivex.core.eventbus.MessageConsumer;
import io.vertx.reactivex.servicediscovery.ServiceDiscovery;
import io.vertx.reactivex.servicediscovery.types.MessageSource;
import io.vertx.workshop.portfolio.reactivex.PortfolioService;
package io.vertx.workshop.trader.impl;


/**
 * A compulsive trader developed with RX Java 2.
 */
public class RXCompulsiveTraderVerticle extends AbstractVerticle {

    @Override
    public void start(Future<Void> future) {
        String company = TraderUtils.pickACompany();
        int numberOfShares = TraderUtils.pickANumber();
        System.out.println("Java-RX compulsive trader configured for company " + company + " and shares: " +
            numberOfShares);


        ServiceDiscovery.create(vertx, discovery -> {
// Path: portfolio-service/src/main/generated/io/vertx/workshop/portfolio/reactivex/PortfolioService.java
// @io.vertx.lang.reactivex.RxGen(io.vertx.workshop.portfolio.PortfolioService.class)
// public class PortfolioService {
// 
//   public static final io.vertx.lang.reactivex.TypeArg<PortfolioService> __TYPE_ARG = new io.vertx.lang.reactivex.TypeArg<>(
//     obj -> new PortfolioService((io.vertx.workshop.portfolio.PortfolioService) obj),
//     PortfolioService::getDelegate
//   );
// 
//   private final io.vertx.workshop.portfolio.PortfolioService delegate;
//   
//   public PortfolioService(io.vertx.workshop.portfolio.PortfolioService delegate) {
//     this.delegate = delegate;
//   }
// 
//   public io.vertx.workshop.portfolio.PortfolioService getDelegate() {
//     return delegate;
//   }
// 
//   /**
//    * Gets the portfolio.
//    * @param resultHandler the result handler called when the portfolio has been retrieved. The async result indicates whether the call was successful or not.
//    */
//   public void getPortfolio(Handler<AsyncResult<Portfolio>> resultHandler) { 
//     delegate.getPortfolio(resultHandler);
//   }
// 
//   /**
//    * Gets the portfolio.
//    * @return 
//    */
//   public Single<Portfolio> rxGetPortfolio() { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Portfolio>(handler -> {
//       getPortfolio(handler);
//     });
//   }
// 
//   /**
//    * Buy `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @param resultHandler the result handler with the updated portfolio. If the action cannot be executed, the async result is market as a failure (not enough money, not enough shares available...)
//    */
//   public void buy(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) { 
//     delegate.buy(amount, quote, resultHandler);
//   }
// 
//   /**
//    * Buy `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @return 
//    */
//   public Single<Portfolio> rxBuy(int amount, JsonObject quote) { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Portfolio>(handler -> {
//       buy(amount, quote, handler);
//     });
//   }
// 
//   /**
//    * Sell `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @param resultHandler the result handler with the updated portfolio. If the action cannot be executed, the async result is market as a failure (not enough share...)
//    */
//   public void sell(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) { 
//     delegate.sell(amount, quote, resultHandler);
//   }
// 
//   /**
//    * Sell `amount` shares of the given shares (quote).
//    * @param amount the amount
//    * @param quote the last quote
//    * @return 
//    */
//   public Single<Portfolio> rxSell(int amount, JsonObject quote) { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Portfolio>(handler -> {
//       sell(amount, quote, handler);
//     });
//   }
// 
//   /**
//    * Evaluates the current value of the portfolio.
//    * @param resultHandler the result handler with the valuation
//    */
//   public void evaluate(Handler<AsyncResult<Double>> resultHandler) { 
//     delegate.evaluate(resultHandler);
//   }
// 
//   /**
//    * Evaluates the current value of the portfolio.
//    * @return 
//    */
//   public Single<Double> rxEvaluate() { 
//     return new io.vertx.reactivex.core.impl.AsyncResultSingle<Double>(handler -> {
//       evaluate(handler);
//     });
//   }
// 
// 
//   public static  PortfolioService newInstance(io.vertx.workshop.portfolio.PortfolioService arg) {
//     return arg != null ? new PortfolioService(arg) : null;
//   }
// }


// Path: compulsive-traders/src/main/java/io/vertx/workshop/trader/impl/RXCompulsiveTraderVerticle.java
import io.reactivex.Single;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.reactivex.core.AbstractVerticle;
import io.vertx.reactivex.core.eventbus.MessageConsumer;
import io.vertx.reactivex.servicediscovery.ServiceDiscovery;
import io.vertx.reactivex.servicediscovery.types.MessageSource;
import io.vertx.workshop.portfolio.reactivex.PortfolioService;

package io.vertx.workshop.trader.impl;


/**
 * A compulsive trader developed with RX Java 2.
 */
public class RXCompulsiveTraderVerticle extends AbstractVerticle {

    @Override
    public void start(Future<Void> future) {
        String company = TraderUtils.pickACompany();
        int numberOfShares = TraderUtils.pickANumber();
        System.out.println("Java-RX compulsive trader configured for company " + company + " and shares: " +
            numberOfShares);


        ServiceDiscovery.create(vertx, discovery -> {
            Single<PortfolioService> retrieveThePortfolioService = RXEventBusService.rxGetProxy(discovery, PortfolioService.class,