/** * Gets the currency. * * @return the currency, never null */ public CurrencyUnit getCurrencyUnit() { return money.getCurrencyUnit(); }
@Override protected Object[] toConvertedColumns(BigMoney value) { return new Object[] { value.getCurrencyUnit(), value.getAmount() }; }
@Override protected Object[] toConvertedColumns(BigMoney value) { return new Object[] { value.getCurrencyUnit(), value.getAmount() }; }
@Override public void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException { appendable.append(Integer.toString(money.getCurrencyUnit().getNumericCode())); } @Override
@Override public void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException { appendable.append(money.getCurrencyUnit().getCode()); } @Override
@Override public void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException { appendable.append(money.getCurrencyUnit().getNumeric3Code()); } @Override
@Override protected Object[] toConvertedColumns(BigMoney value) { return new Object[] { value.getCurrencyUnit(), value.getAmountMajorLong() }; }
@Override protected Object[] toConvertedColumns(BigMoney value) { return new Object[] { value.getCurrencyUnit(), value.getAmountMajorLong() }; }
@Override protected Object[] toConvertedColumns(BigMoney value) { return new Object[] { value.getCurrencyUnit(), value.getAmountMinorLong() }; }
@Override protected Object[] toConvertedColumns(BigMoney value) { return new Object[] { value.getCurrencyUnit(), value.getAmountMinorLong() }; }
/** * Validates that the currency of this money and the specified money match. * * @param moneyProvider the money to check, not null * @throws CurrencyMismatchException if the currencies differ */ private BigMoney checkCurrencyEqual(BigMoneyProvider moneyProvider) { BigMoney money = of(moneyProvider); if (isSameCurrency(money) == false) { throw new CurrencyMismatchException(getCurrencyUnit(), money.getCurrencyUnit()); } return money; }
private void writeBigMoney(ObjectOutput out, BigMoney obj) throws IOException { writeCurrency(out, obj.getCurrencyUnit()); byte[] bytes = obj.getAmount().unscaledValue().toByteArray(); out.writeInt(bytes.length); out.write(bytes); out.writeInt(obj.getScale()); }
@Override public Long toNonNullValue(BigMoney value) { if (!currencyUnit.equals(value.getCurrencyUnit())) { throw new IllegalStateException("Expected currency " + currencyUnit.getCurrencyCode() + " but was " + value.getCurrencyUnit()); } return value.toBigMoney().getAmountMinorLong(); }
@Override public void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException { appendable.append(money.getCurrencyUnit().getSymbol(context.getLocale())); } @Override
private void updateBooks() { wallets = accountInfo.getWallets(); for(Wallet wallet : wallets){ CurrencyUnit currency = wallet.getBalance().getCurrencyUnit(); //Do we have a new currency in our wallet? if(!books.containsKey(currency)){ //Make some space for it. books.put(currency,new ArrayList<BigMoney>()); } ArrayList<BigMoney> ledger = books.get(currency); ledger.add(wallet.getBalance()); } }
@Override public Long toNonNullValue(BigMoney value) { if (!currencyUnit.equals(value.getCurrencyUnit())) { throw new IllegalStateException("Expected currency " + currencyUnit.getCurrencyCode() + " but was " + value.getCurrencyUnit()); } return value.toBigMoney().getAmountMajorLong(); }
@Override public BigDecimal toNonNullValue(BigMoney value) { if (!currencyUnit.equals(value.getCurrencyUnit())) { throw new IllegalStateException("Expected currency " + currencyUnit.getCurrencyCode() + " but was " + value.getCurrencyUnit()); } return BigMoney.of(value).getAmount(); }
/** * Checks if this instance and the specified instance have the same currency. * * @param money the money to check, not null * @return true if they have the same currency */ public boolean isSameCurrency(BigMoneyProvider money) { return (currency.equals(of(money).getCurrencyUnit())); }
public void addTick(ATPTicker tick) { CurrencyUnit currency = CurrencyUnit.getInstance(tick.getLast().getCurrencyUnit().getCurrencyCode()); if(!currency.getCode().equals("BTC")) { synchronized(lastTickMap) { lastTickMap.put(currency, tick); } } }
public BigMoney getBalance(CurrencyUnit currency) throws WalletNotFoundException{ refreshAccounts(); wallets = accountInfo.getWallets(); for(Wallet wallet : wallets){ BigMoney balance = wallet.getBalance(); CurrencyUnit unit = balance.getCurrencyUnit(); if(unit.equals(currency)){ return balance; } } log.error("ERROR: Could not find a {} wallet for the currency {}. Exiting now!",exchangeName,currency); throw new WalletNotFoundException(); }