|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.math.MoneyConverter
public class MoneyConverter
provides money exchange rates
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.antelmann.util.Converter |
|---|
Converter.Adapter<T1,T2> |
| Constructor Summary | |
|---|---|
MoneyConverter()
|
|
MoneyConverter(Currency baseCurrency)
|
|
| Method Summary | ||
|---|---|---|
BigDecimal |
addCurrency(Currency c,
BigDecimal exchangeRate)
returns the previously set exchange rate or null |
|
BigDecimal |
addCurrency(Currency c,
double exchangeRate)
|
|
|
aggregate(Map<T,Money> data,
PatternExtractor<T,P> pattern)
all Money is converted into the base currency |
|
int |
compare(Money m1,
Money m2)
If the currencies are not equal, they are compared based on the baseCurrency. |
|
boolean |
contains(Currency c)
|
|
Money |
convert(Measurable m,
Unit targetUnit)
converts the given measurable into the target unit and returns the resulting measurable |
|
Money |
convert(Money m)
converts to the base currency |
|
Money |
convertBack(Money obj)
always throws UnsupportedOperationException as it is not clear what currency is desired |
|
Money |
convertToBaseCurrency(Money m)
|
|
Money |
convertToCurrency(Money m,
Currency c)
|
|
Currency |
getBaseCurrency()
|
|
BigDecimal |
getExchangeRate(Currency c)
|
|
BigDecimal |
getExchangeRate(Money m)
|
|
Set<Currency> |
getKnownCurrencies()
returns an unmodifiable view of the known currencies |
|
BigDecimal |
removeCurrency(Currency c)
returns the exchange rate that was previously set or null |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Constructor Detail |
|---|
public MoneyConverter()
public MoneyConverter(Currency baseCurrency)
| Method Detail |
|---|
public Currency getBaseCurrency()
public boolean contains(Currency c)
public Set<Currency> getKnownCurrencies()
public BigDecimal getExchangeRate(Currency c)
public BigDecimal getExchangeRate(Money m)
public BigDecimal addCurrency(Currency c,
double exchangeRate)
public BigDecimal addCurrency(Currency c,
BigDecimal exchangeRate)
public BigDecimal removeCurrency(Currency c)
public Money convertToBaseCurrency(Money m)
throws WrongCurrencyException
WrongCurrencyException
public Money convertToCurrency(Money m,
Currency c)
public int compare(Money m1,
Money m2)
throws WrongCurrencyException
compare in interface Comparator<Money>WrongCurrencyException - if any given currency is not known to this instance
public <P,T> HashMap<P,Money> aggregate(Map<T,Money> data,
PatternExtractor<T,P> pattern)
throws WrongCurrencyException
WrongCurrencyExceptionpublic Money convert(Money m)
convert in interface Converter<Money,Money>WrongCurrencyException - if the given currency is unknowngetBaseCurrency()
public Money convertBack(Money obj)
throws UnsupportedOperationException
convertBack in interface Converter<Money,Money>UnsupportedOperationException
public Money convert(Measurable m,
Unit targetUnit)
throws IllegalArgumentException,
UnsupportedOperationException
UnitConverter
convert in interface UnitConverterm - the original measurable to be convertedtargetUnit - the desired unit
IllegalArgumentException - if this converter cannot handle any of the given units
UnsupportedOperationException - if the units of the given measurable and the target unit are not convertible
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||