public static AccountInfo adaptAccountInfo ( CoingiBalances coingiBalances , String userName ) { List < Balance > balances = new ArrayList <> ( ) ; for ( CoingiBalance coingiBalance : coingiBalances . getList ( ) ) { BigDecimal total = coingiBalance . getAvailable ( ) . add ( coingiBalance . getBlocked ( ) ) . add ( coingiBalance . getWithdrawing ( ) ) . add ( coingiBalance . getDeposited ( ) ) ; Balance xchangeBalance = new Balance ( Currency . getInstance ( coingiBalance . getCurrency ( ) . getName ( ) . toUpperCase ( ) ) , total , // total = available + frozen - borrowed + loaned + withdrawing + depositing coingiBalance . getAvailable ( ) , // available coingiBalance . getBlocked ( ) , BigDecimal . ZERO , // borrowed is always 0 BigDecimal . ZERO , // loaned is always 0 coingiBalance . getWithdrawing ( ) , coingiBalance . getDeposited ( ) ) ; balances . add ( xchangeBalance ) ; } return new AccountInfo ( userName , new Wallet ( balances ) ) ; }
Adapts a CoingiBalances to an AccountInfo