Interface ChangeSource
- All Known Implementing Classes:
Bank
public interface ChangeSource
Interface for currency exchange rate providers.
Implementations retrieve current exchange rates from various sources such as banks, financial exchanges, or online services. Modernized to use Real for exchange rates to ensure high precision.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptiongetConverted(Money amount, Currency target) Converts an amount from one currency to another.default RealgetExchangeRate(Currency source, Currency target) Returns the current exchange rate between two currencies.default doublegetExchangeRateValue(Currency source, Currency target) Returns the current exchange rate between two currencies as double.
-
Method Details
-
getConverted
Converts an amount from one currency to another.- Parameters:
amount- the amount to converttarget- the target currency- Returns:
- the converted amount in the target currency
- Throws:
UnavailableDataException- if exchange rate data cannot be retrieved
-
getExchangeRate
Returns the current exchange rate between two currencies. Use Real for internal and API representation.- Parameters:
source- the source currencytarget- the target currency- Returns:
- the exchange rate as Real (units of target per unit of source)
- Throws:
UnavailableDataException- if exchange rate data cannot be retrieved
-
getExchangeRateValue
default double getExchangeRateValue(Currency source, Currency target) throws UnavailableDataException Returns the current exchange rate between two currencies as double. Convenience method for display or export.- Throws:
UnavailableDataException
-