diff --git a/java-examples/src/main/java/bisq/bots/BotUtils.java b/java-examples/src/main/java/bisq/bots/BotUtils.java index ed62585..8bbc236 100644 --- a/java-examples/src/main/java/bisq/bots/BotUtils.java +++ b/java-examples/src/main/java/bisq/bots/BotUtils.java @@ -42,6 +42,7 @@ import static java.lang.String.format; import static java.lang.System.*; import static java.math.BigDecimal.ZERO; import static java.math.RoundingMode.HALF_UP; +import static java.util.Objects.requireNonNull; /** * Convenience methods and functions not depending on a bot's state nor the need to send requests to the API daemon. @@ -407,6 +408,7 @@ public class BotUtils { * @param offer printed offer */ public static void printOfferSummary(OfferInfo offer) { + requireNonNull(offer, "OfferInfo offer param cannot be null."); new TableBuilder(OFFER_TBL, offer).build().print(out); } @@ -416,7 +418,12 @@ public class BotUtils { * @param offers printed offer list */ public static void printOffersSummary(List offers) { - new TableBuilder(OFFER_TBL, offers).build().print(out); + requireNonNull(offers, "List offers param cannot be null."); + if (offers.isEmpty()) { + log.info("No offers to print."); + } else { + new TableBuilder(OFFER_TBL, offers).build().print(out); + } } /** @@ -425,6 +432,7 @@ public class BotUtils { * @param trade printed trade */ public static void printTradeSummary(TradeInfo trade) { + requireNonNull(trade, "TradeInfo trade param cannot be null."); new TableBuilder(TRADE_DETAIL_TBL, trade).build().print(out); } @@ -435,10 +443,15 @@ public class BotUtils { * @param trades list of trades */ public static void printTradesSummary(GetTradesRequest.Category category, List trades) { - switch (category) { - case CLOSED -> new TableBuilder(CLOSED_TRADES_TBL, trades).build().print(out); - case FAILED -> new TableBuilder(FAILED_TRADES_TBL, trades).build().print(out); - default -> new TableBuilder(OPEN_TRADES_TBL, trades).build().print(out); + requireNonNull(trades, "List trades param cannot be null."); + if (trades.isEmpty()) { + log.info("No trades to print."); + } else { + switch (category) { + case CLOSED -> new TableBuilder(CLOSED_TRADES_TBL, trades).build().print(out); + case FAILED -> new TableBuilder(FAILED_TRADES_TBL, trades).build().print(out); + default -> new TableBuilder(OPEN_TRADES_TBL, trades).build().print(out); + } } } @@ -448,6 +461,7 @@ public class BotUtils { * @param paymentAccount the printed PaymentAccount */ public static void printPaymentAccountSummary(PaymentAccount paymentAccount) { + requireNonNull(paymentAccount, "PaymentAccount paymentAccount param cannot be null."); new TableBuilder(PAYMENT_ACCOUNT_TBL, paymentAccount).build().print(out); }