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 Details

    • getConverted

      Money getConverted(Money amount, Currency target) throws UnavailableDataException
      Converts an amount from one currency to another.
      Parameters:
      amount - the amount to convert
      target - the target currency
      Returns:
      the converted amount in the target currency
      Throws:
      UnavailableDataException - if exchange rate data cannot be retrieved
    • getExchangeRate

      default Real getExchangeRate(Currency source, Currency target) throws UnavailableDataException
      Returns the current exchange rate between two currencies. Use Real for internal and API representation.
      Parameters:
      source - the source currency
      target - 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