/** * Constructs an {@link AccountInfo}. * * @param username the user name. * @param tradingFee the trading fee. * @param wallets the user's wallets */ public AccountInfo(String username, BigDecimal tradingFee, Collection<Wallet> wallets) { this.username = username; this.tradingFee = tradingFee; if (wallets.size() == 0) { this.wallets = Collections.emptyMap(); } else if (wallets.size() == 1) { Wallet wallet = wallets.iterator().next(); this.wallets = Collections.singletonMap(wallet.getId(), wallet); } else { this.wallets = new HashMap<>(); for (Wallet wallet : wallets) { if (this.wallets.containsKey(wallet.getId())) { throw new IllegalArgumentException("duplicate wallets passed to AccountInfo"); } this.wallets.put(wallet.getId(), wallet); } } }
/** * Constructs an {@link AccountInfo}. * * @param username the user name. * @param tradingFee the trading fee. * @param wallets the user's wallets */ public AccountInfo(String username, BigDecimal tradingFee, Collection<Wallet> wallets) { this.username = username; this.tradingFee = tradingFee; if (wallets.size() == 0) { this.wallets = Collections.emptyMap(); } else if (wallets.size() == 1) { Wallet wallet = wallets.iterator().next(); this.wallets = Collections.singletonMap(wallet.getId(), wallet); } else { this.wallets = new HashMap<>(); for (Wallet wallet : wallets) { if (this.wallets.containsKey(wallet.getId())) { throw new IllegalArgumentException("duplicate wallets passed to AccountInfo"); } this.wallets.put(wallet.getId(), wallet); } } }