Class FileExchangeRateProvider

    • Constructor Detail

      • FileExchangeRateProvider

        public FileExchangeRateProvider()
    • Method Detail

      • getExchangeRate

        public double getExchangeRate​(String sourceCurrencyCode,
                                      String targetCurrencyCode)
        Returns the currently known exchange rate between two currencies. If a direct rate has been loaded, it is used. Otherwise, if a rate is known to convert the target currency to the source, the inverse exchange rate is computed.
        Specified by:
        getExchangeRate in interface ExchangeRateProvider
        Parameters:
        sourceCurrencyCode - The source currency being converted from.
        targetCurrencyCode - The target currency being converted to.
        Returns:
        The exchange rate.
        Throws:
        SolrException - if the requested currency pair cannot be found
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • reload

        public boolean reload()
                       throws SolrException
        Description copied from interface: ExchangeRateProvider
        Ask the currency provider to explicitly reload/refresh its configuration. If this does not make sense for a particular provider, simply do nothing
        Specified by:
        reload in interface ExchangeRateProvider
        Returns:
        true if reload of rates succeeded, else false
        Throws:
        SolrException - if there is a problem reloading
      • init

        public void init​(Map<String,​String> params)
                  throws SolrException
        Description copied from interface: ExchangeRateProvider
        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

        Specified by:
        init in interface ExchangeRateProvider
        Parameters:
        params - a @Map of key/value config params to initialize the provider
        Throws:
        SolrException
      • inform

        public void inform​(org.apache.lucene.analysis.util.ResourceLoader loader)
                    throws SolrException
        Description copied from interface: ExchangeRateProvider
        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

        Specified by:
        inform in interface ExchangeRateProvider
        Parameters:
        loader - a @ResourceLoader instance
        Throws:
        SolrException