Interface ScenarioFxConvertible<R>

  • Type Parameters:
    R - the type of the currency converted result
    All Known Implementing Classes:
    CurrencyScenarioArray, MultiCurrencyScenarioArray

    public interface ScenarioFxConvertible<R>
    Provides the ability for objects to be automatically currency converted.

    The interface is intended to operate with multi-scenario objects. As such, the supplied market data is scenario aware, and the FX rate used to convert each value may be different.

    For example, the object implementing this interface might hold 100 instances of CurrencyAmount, one for each scenario. When invoked, the ScenarioFxRateProvider will be used to convert each of the 100 amounts, with each conversion potentially having a different FX rate.

    This is the multi-scenario version of FxConvertible.

    • Method Detail

      • convertedTo

        R convertedTo​(Currency resultCurrency,
                      ScenarioFxRateProvider rateProvider)
        Converts this instance to an equivalent amount in the specified currency.

        The result, which may be of a different type, will be expressed in terms of the given currency. Any FX conversion that is required will use rates from the provider.

        Any object that is not a currency amount will be left unchanged. The number of scenarios of this instance must match the number of scenarios of the specified provider.

        Parameters:
        resultCurrency - the currency of the result
        rateProvider - the multi-scenario provider of FX rates
        Returns:
        the converted instance, which should be expressed in the specified currency
        Throws:
        RuntimeException - if no FX rate could be found