RippleAdapters { public static AccountInfo adaptAccountInfo( final RippleAccountBalances account, final String username) { final Map<String, List<Balance>> balances = new HashMap<>(); for (final RippleBalance balance : account.getBalances()) { final String walletId; if (balance.getCurrency().equals("XRP")) { walletId = "main"; } else { walletId = balance.getCounterparty(); } if (!balances.containsKey(walletId)) { balances.put(walletId, new LinkedList<Balance>()); } balances .get(walletId) .add(new Balance(Currency.getInstance(balance.getCurrency()), balance.getValue())); } final List<Wallet> accountInfo = new ArrayList<>(balances.size()); for (final Map.Entry<String, List<Balance>> wallet : balances.entrySet()) { accountInfo.add(Wallet.Builder.from(wallet.getValue()).id(wallet.getKey()).build()); } return new AccountInfo(username, BigDecimal.ZERO, accountInfo); } private  RippleAdapters(); static AccountInfo adaptAccountInfo(
      final RippleAccountBalances account, final String username); static OrderBook adaptOrderBook(
      final RippleOrderBook rippleOrderBook,
      final RippleMarketDataParams params,
      final CurrencyPair currencyPair); static List<LimitOrder> createOrders(
      final CurrencyPair currencyPair,
      final OrderType orderType,
      final List<RippleOrder> orders,
      final String baseCounterparty,
      final String counterCounterparty); static OpenOrders adaptOpenOrders(
      final RippleAccountOrders rippleOrders, final int scale); static UserTrade adaptTrade(
      final IRippleTradeTransaction trade,
      final TradeHistoryParams params,
      final ITransferFeeSource transferFeeSource,
      final int scale); static UserTrades adaptTrades(
      final Collection<IRippleTradeTransaction> tradesForAccount,
      final TradeHistoryParams params,
      final RippleAccountService accountService,
      final int roundingScale);  }
@Test public void adaptAccountInfoTest() throws IOException { final InputStream is = getClass() .getResourceAsStream( "/org/knowm/xchange/ripple/dto/account/example-account-balances.json"); final ObjectMapper mapper = new ObjectMapper(); final RippleAccountBalances rippleAccount = mapper.readValue(is, RippleAccountBalances.class); final AccountInfo account = RippleAdapters.adaptAccountInfo(rippleAccount, "username"); assertThat(account.getWallets()).hasSize(2); assertThat(account.getUsername()).isEqualTo("username"); assertThat(account.getTradingFee()).isEqualTo(BigDecimal.ZERO); final Wallet counterWallet = account.getWallet("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"); assertThat(counterWallet.getId()).isEqualTo("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"); assertThat(counterWallet.getBalances()).hasSize(2); final Balance btcBalance = counterWallet.getBalance(Currency.BTC); assertThat(btcBalance.getTotal()).isEqualTo("0.038777349225374"); assertThat(btcBalance.getCurrency()).isEqualTo(Currency.BTC); final Balance usdBalance = counterWallet.getBalance(Currency.USD); assertThat(usdBalance.getTotal()).isEqualTo("10"); assertThat(usdBalance.getCurrency()).isEqualTo(Currency.USD); final Wallet mainWallet = account.getWallet("main"); assertThat(mainWallet.getBalances()).hasSize(1); final Balance xrpBalance = mainWallet.getBalance(Currency.XRP); assertThat(xrpBalance.getTotal()).isEqualTo("861.401578"); assertThat(xrpBalance.getCurrency()).isEqualTo(Currency.XRP); }