BittrexAdapters { protected static BigDecimal calculateFrozenBalance(BittrexBalance balance) { if (balance.getBalance() == null) { return BigDecimal.ZERO; } final BigDecimal[] frozenBalance = {balance.getBalance()}; Optional.ofNullable(balance.getAvailable()) .ifPresent(available -> frozenBalance[0] = frozenBalance[0].subtract(available)); Optional.ofNullable(balance.getPending()) .ifPresent(pending -> frozenBalance[0] = frozenBalance[0].subtract(pending)); return frozenBalance[0]; } private  BittrexAdapters(); static List<CurrencyPair> adaptCurrencyPairs(Collection<BittrexSymbol> bittrexSymbol); static CurrencyPair adaptCurrencyPair(BittrexSymbol bittrexSymbol); static List<LimitOrder> adaptOpenOrders(List<BittrexOpenOrder> bittrexOpenOrders); static LimitOrder adaptOrder(BittrexOrderBase order, OrderStatus status); static List<LimitOrder> adaptOrders(
      BittrexLevel[] orders, CurrencyPair currencyPair, String orderType, String id, int depth); static LimitOrder adaptOrder(
      BigDecimal amount,
      BigDecimal price,
      CurrencyPair currencyPair,
      String orderTypeString,
      String id); static LimitOrder adaptOrder(BittrexOrder order); static LimitOrder adaptOrder(BittrexOpenOrder order); static Trade adaptTrade(BittrexTrade trade, CurrencyPair currencyPair); static Trades adaptTrades(List<BittrexTrade> trades, CurrencyPair currencyPair); static Ticker adaptTicker(BittrexMarketSummary marketSummary, CurrencyPair currencyPair); static Wallet adaptWallet(List<BittrexBalance> balances); static Balance adaptBalance(BittrexBalance balance); static List<UserTrade> adaptUserTrades(List<BittrexUserTrade> bittrexUserTrades); static UserTrade adaptUserTrade(BittrexUserTrade trade); static ExchangeMetaData adaptMetaData(
      List<BittrexSymbol> rawSymbols, ExchangeMetaData metaData); static List<FundingRecord> adaptDepositRecords(
      List<BittrexDepositHistory> bittrexFundingHistories); static List<FundingRecord> adaptWithdrawalRecords(
      List<BittrexWithdrawalHistory> bittrexFundingHistories); static final Logger log; }
@Test public void testCalculateFrozenBalance() { BittrexBalance balance = new BittrexBalance(null, null, null, null, null, false, null); Assert.assertEquals(BigDecimal.ZERO, BittrexAdapters.calculateFrozenBalance(balance)); balance = new BittrexBalance( BigDecimal.ONE, new BigDecimal("100"), null, null, BigDecimal.TEN, false, null); Assert.assertEquals(new BigDecimal("89"), BittrexAdapters.calculateFrozenBalance(balance)); balance = new BittrexBalance(null, new BigDecimal("100"), null, null, null, false, null); Assert.assertEquals(new BigDecimal("100"), BittrexAdapters.calculateFrozenBalance(balance)); }