MoneyContext
MoneyContext
MoneyContext
Provides a context for Money specific operations.
When provided as an implicit parameter, the defaultCurrency will be used by the Money factory when no other currency is provided.
Provides for cross-currency conversions.
Will act as an implicit parameter to cross currency operations to allow for easy conversions
- Value Params
- defaultCurrency
Currency used when none is supplied to the Money factory
- rates
Collection of Exchange Rates used for currency conversions
- Authors
garyKeorkunian
- Since
0.1
Value members
Concrete methods
Adds two money values that may or may not be in the same currency.
Adds two money values that may or may not be in the same currency.
The result will be in the same currency as the first parameter.
- Value Params
- moneyA
Money A
- moneyB
Money B
- Throws
- NoSuchExchangeRateException
when no exchange rate is available
Performs a standard compare on two money values that may or may not be in the same currency
Performs a standard compare on two money values that may or may not be in the same currency
- Value Params
- moneyA
Money A
- moneyB
Money B
- Throws
- NoSuchExchangeRateException
when no exchange rate is available
Converts a Money value to the specified currency.
Converts a Money value to the specified currency.
The conversion first attempts to use an existing exchange rate for the two currencies in question. If no direct exchange works, a cross rate (limited to 1 hop) will be calculated and used. If no cross rate can be calculated a NoSuchElementException is thrown
- Value Params
- currency
Currency to be converted to
- money
Money to be converted
- Throws
- NoSuchExchangeRateException
when no exchange rate is available
Returns an Option on an exchange rate if a direct rate exists, otherwise None
Returns an Option on an exchange rate if a direct rate exists, otherwise None
- Value Params
- curA
Currency A
- curB
Currency B
Divides two money value that may or may not be in the same currency after converting the second to the first
Divides two money value that may or may not be in the same currency after converting the second to the first
- Value Params
- moneyA
Money A
- moneyB
Money B
Return an Option on an exchange rate. If a direct rate exists an Option on that will be returned. Otherwise, if a cross rate can be determined (1 hop limit), it will be created and returned in an Option. Otherwise, None will be returned
Return an Option on an exchange rate. If a direct rate exists an Option on that will be returned. Otherwise, if a cross rate can be determined (1 hop limit), it will be created and returned in an Option. Otherwise, None will be returned
- Value Params
- curA
Currency A
- curB
Currency B
Subtracts two money values that may or may not be in the same currency
Subtracts two money values that may or may not be in the same currency
The result will be in the same currency as the first parameter.
- Value Params
- moneyA
Money A
- moneyB
Money B
- Throws
- NoSuchExchangeRateException
when no exchange rate is available
Custom implementation using SortedSets to ensure consistent output
Custom implementation using SortedSets to ensure consistent output
- Returns
String representation of this instance
- Definition Classes
- Any
Create a copy of this context with additional currencies added to the existing set
Create a copy of this context with additional currencies added to the existing set
- Value Params
- additionalCurrencies
Set[Currency]