...
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
package org.mai.dep810.cer; import java.math.BigDecimal; import java.util.Currency; public class CurrencyExchangeRate { BigDecimal rate; Currency from; Currency to; public CurrencyExchangeRate(BigDecimal rate, Currency from, Currency to) { this.rate = rate; this.from = from; this.to = to; } public Money convert(Money m) { if(m.getCurrency().equals(from)) { return new Money(to, m.getAmount().multiply(rate)); } else { throw new IncorrectExchangeRateException("Unable to convert currency "+m.getCurrency().getCurrencyCode() + " from "+from.getCurrencyCode()); } } } |
Альтернативные библиотеки коллекций
Apache Commons Collections
Home page: http://commons.apache.org/proper/commons-collections/
Google Guava
Home page: https://code.google.com/archive/p/google-collections/
User guide: https://github.com/google/guava/wiki
Материалы
Презентация: JavaCollections.pptx
...