Interface ExchangeRateProvider

All Known Implementing Classes:
FileExchangeRateProvider, OpenExchangeRatesOrgProvider

public interface ExchangeRateProvider
Interface for providing pluggable exchange rate providers to CurrencyFieldType
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getExchangeRate(String sourceCurrencyCode, String targetCurrencyCode)
    Get the exchange rate between the two given currencies
    void
    inform(org.apache.lucene.util.ResourceLoader loader)
    Passes a ResourceLoader, used to read config files from e.g.
    void
    Initializes the provider by passing in a set of key/value configs as a map.
    List all configured currency codes which are valid as source/target for this Provider
    boolean
    Ask the currency provider to explicitly reload/refresh its configuration.
  • Method Details

    • getExchangeRate

      double getExchangeRate(String sourceCurrencyCode, String targetCurrencyCode) throws org.apache.solr.common.SolrException
      Get the exchange rate between the two given currencies
      Returns:
      the exchange rate as a double
      Throws:
      org.apache.solr.common.SolrException - if the rate is not defined in the provider
    • listAvailableCurrencies

      Set<String> listAvailableCurrencies()
      List all configured currency codes which are valid as source/target for this Provider
      Returns:
      a Set of ISO 4217 currency code strings
    • reload

      boolean reload() throws org.apache.solr.common.SolrException
      Ask the currency provider to explicitly reload/refresh its configuration. If this does not make sense for a particular provider, simply do nothing
      Returns:
      true if reload of rates succeeded, else false
      Throws:
      org.apache.solr.common.SolrException - if there is a problem reloading
    • init

      void init(Map<String,String> args)
      Initializes the provider by passing in a set of key/value configs as a map. Note that the map also contains other fieldType parameters, so make sure to avoid name clashes.

      Important: Custom config params must be removed from the map before returning

      Parameters:
      args - a @Map of key/value config params to initialize the provider
    • inform

      void inform(org.apache.lucene.util.ResourceLoader loader) throws org.apache.solr.common.SolrException
      Passes a ResourceLoader, used to read config files from e.g. ZooKeeper. Implementations not needing resource loader can implement this as NOOP.

      Typically called after init

      Parameters:
      loader - a @ResourceLoader instance
      Throws:
      org.apache.solr.common.SolrException