BitcoindeAdapters { public static List<FundingRecord> adaptFundingHistory( final Currency currency, final List<BitcoindeAccountLedger> accountLedgers, final boolean leaveFeesSeperate) { List<BitcoindeAccountLedger> feeLedgers = accountLedgers.stream() .filter(ledger -> !leaveFeesSeperate && OUTGOING_FEE_VOLUNTARY == ledger.getType()) .collect(Collectors.toList()); return accountLedgers.stream() .filter(ledger -> SELL != ledger.getType() && BUY != ledger.getType()) .filter(ledger -> leaveFeesSeperate || OUTGOING_FEE_VOLUNTARY != ledger.getType()) .map( ledger -> { FundingRecord.Type type = adaptFundingRecordType(ledger.getType()); FundingRecord.Builder builder = new FundingRecord.Builder() .setType(type) .setDate(ledger.getDate()) .setCurrency(currency) .setAmount(ledger.getCashflow().abs()) .setBalance(ledger.getBalance()) .setStatus(FundingRecord.Status.COMPLETE) .setDescription(ledger.getType().getValue()); if (INPAYMENT == ledger.getType() || PAYOUT == ledger.getType()) { builder.setBlockchainTransactionHash(ledger.getReference()); } else { builder.setInternalId(ledger.getReference()); } if (!leaveFeesSeperate && PAYOUT == ledger.getType()) { Optional<BitcoindeAccountLedger> feeLedger = findFeeLedger(ledger.getReference(), feeLedgers); if (feeLedger.isPresent()) { BigDecimal fee = feeLedger.get().getCashflow().abs(); builder.setAmount(ledger.getCashflow().abs().add(fee)); builder.setFee(fee); feeLedgers.remove(feeLedger.get()); } } return builder.build(); }) .collect(Collectors.toList()); } private  BitcoindeAdapters(); static OrderBook adaptCompactOrderBook(
      BitcoindeCompactOrderbookWrapper bitcoindeOrderbookWrapper, CurrencyPair currencyPair); static OrderBook adaptOrderBook(
      BitcoindeOrderbookWrapper asksWrapper,
      BitcoindeOrderbookWrapper bidsWrapper,
      CurrencyPair currencyPair); static List<LimitOrder> createCompactOrders(
      CurrencyPair currencyPair, OrderType orderType, BitcoindeCompactOrder[] orders); static LimitOrder createOrder(
      CurrencyPair currencyPair,
      BitcoindeOrder bitcoindeOrder,
      OrderType orderType,
      String orderId,
      Date timeStamp); static Trades adaptTrades(
      BitcoindeTradesWrapper bitcoindeTradesWrapper, CurrencyPair currencyPair); static AccountInfo adaptAccountInfo(BitcoindeAccountWrapper bitcoindeAccount); static List<FundingRecord> adaptFundingHistory(
      final Currency currency,
      final List<BitcoindeAccountLedger> accountLedgers,
      final boolean leaveFeesSeperate); static FundingRecord.Type adaptFundingRecordType(BitcoindeAccountLedgerType type); static UserTrades adaptTradeHistory(BitcoindeMyTradesWrapper bitcoindeMyTradesWrapper); static UserTrades adaptTradeHistory(
      BitcoindeMyTradesWrapper bitcoindeMyTradesWrapper, TradeSortType sortType); static OpenOrders adaptOpenOrders(BitcoindeMyOrdersWrapper bitcoindeOpenOrdersWrapper); static OrderType adaptOrderType(final BitcoindeType type); static OrderStatus adaptOrderStatus(final BitcoindeOrderState state);  }
@Test public void testFundingHistoryAdapter() throws IOException { final InputStream is = BitcoindeAdaptersTest.class.getResourceAsStream( "/org/knowm/xchange/bitcoinde/v4/dto/account_ledger.json"); final ObjectMapper mapper = new ObjectMapper(); BitcoindeAccountLedgerWrapper accountLedgerWrapper = mapper.readValue(is, BitcoindeAccountLedgerWrapper.class); final List<FundingRecord> fundingRecords = BitcoindeAdapters.adaptFundingHistory( Currency.BTC, accountLedgerWrapper.getAccountLedgers(), false); assertThat(fundingRecords).isNotEmpty(); assertThat(fundingRecords.size()).isEqualTo(2); assertThat(fundingRecords.get(0).getAddress()).isNull(); assertThat(fundingRecords.get(0).getAddressTag()).isNull(); assertThat(fundingRecords.get(0).getDate()).isEqualTo("2015-08-12T13:05:02+02:00"); assertThat(fundingRecords.get(0).getCurrency()).isEqualByComparingTo(Currency.BTC); assertThat(fundingRecords.get(0).getAmount()).isEqualByComparingTo("0.10000000"); assertThat(fundingRecords.get(0).getInternalId()).isNull(); assertThat(fundingRecords.get(0).getBlockchainTransactionHash()) .isEqualTo("dqwdqwdwqwq4dqw4d5qd45qd45qwd4qw5df45g4r5g4trh4r5j5j4tz5j4tbc"); assertThat(fundingRecords.get(0).getType()).isEqualByComparingTo(FundingRecord.Type.WITHDRAWAL); assertThat(fundingRecords.get(0).getBalance()).isEqualByComparingTo("4.71619794"); assertThat(fundingRecords.get(0).getStatus()) .isEqualByComparingTo(FundingRecord.Status.COMPLETE); assertThat(fundingRecords.get(0).getFee()).isNull(); assertThat(fundingRecords.get(0).getDescription()) .isEqualTo(BitcoindeAccountLedgerType.PAYOUT.getValue()); assertThat(fundingRecords.get(1).getAddress()).isNull(); assertThat(fundingRecords.get(1).getAddressTag()).isNull(); assertThat(fundingRecords.get(1).getDate()).isEqualTo("2015-08-12T12:30:01+02:00"); assertThat(fundingRecords.get(1).getCurrency()).isEqualByComparingTo(Currency.BTC); assertThat(fundingRecords.get(1).getAmount()).isEqualByComparingTo("1.91894200"); assertThat(fundingRecords.get(1).getInternalId()).isNull(); assertThat(fundingRecords.get(1).getBlockchainTransactionHash()) .isEqualTo("bdgwflwguwgr884t34g4g555h4zr5j4fh5j48rg4s5bx2nt4jr5jr45j4r5j4"); assertThat(fundingRecords.get(1).getType()).isEqualByComparingTo(FundingRecord.Type.WITHDRAWAL); assertThat(fundingRecords.get(1).getBalance()).isEqualByComparingTo("4.81619794"); assertThat(fundingRecords.get(1).getStatus()) .isEqualByComparingTo(FundingRecord.Status.COMPLETE); assertThat(fundingRecords.get(1).getFee()).isNull(); assertThat(fundingRecords.get(1).getDescription()) .isEqualTo(BitcoindeAccountLedgerType.PAYOUT.getValue()); }