Tabnine Logo
ExchangeRateProvider.isAvailable
Code IndexAdd Tabnine to your IDE (free)

How to use
isAvailable
method
in
javax.money.convert.ExchangeRateProvider

Best Java code snippets using javax.money.convert.ExchangeRateProvider.isAvailable (Showing top 4 results out of 315)

origin: javax.money/money-api

/**
 * Checks if an {@link ExchangeRate} between two {@link CurrencyUnit} is
 * available from this provider. This method should check, if a given rate
 * is <i>currently</i> defined.
 *
 * @param baseCode the base currency code
 * @param termCode the terminal/target currency code
 * @return {@code true}, if such an {@link ExchangeRate} is currently
 * defined.
 * @throws MonetaryException if one of the currency codes passed is not valid.
 */
default boolean isAvailable(String baseCode, String termCode){
  return isAvailable(Monetary.getCurrency(baseCode), Monetary.getCurrency(termCode));
}
origin: org.javamoney.moneta/moneta-core

@Override
public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) {
  for (ExchangeRateProvider prov : this.providers) {
    try {
      if (prov.isAvailable(conversionQuery)) {
        ExchangeRate rate = prov.getExchangeRate(conversionQuery);
        if (Objects.nonNull(rate)) {
          return rate;
        }
      }
    } catch (Exception e) {
      Logger.getLogger(getClass().getName()).log(Level.WARNING,
          "Rate Provider did not return data though at check before data was flagged as available," +
              " provider=" + prov.getContext().getProviderName() + ", query=" + conversionQuery);
    }
  }
  throw new CurrencyConversionException(conversionQuery.getBaseCurrency(), conversionQuery.getCurrency(), null,
      "All delegate prov iders failed to deliver rate, providers=" + this.providers +
          ", query=" + conversionQuery);
}
origin: javax.money/money-api

/**
 * Checks if an {@link ExchangeRate} between two {@link CurrencyUnit} is
 * available from this provider. This method should check, if a given rate
 * is <i>currently</i> defined.
 *
 * @param base the base {@link CurrencyUnit}
 * @param term the term {@link CurrencyUnit}
 * @return {@code true}, if such an {@link ExchangeRate} is currently
 * defined.
 */
default boolean isAvailable(CurrencyUnit base, CurrencyUnit term){
  return isAvailable(ConversionQueryBuilder.of().setBaseCurrency(base).setTermCurrency(term).build());
}
origin: javax.money/money-api

/**
 * The method reverses the {@link ExchangeRate} to a rate mapping from term
 * to base {@link CurrencyUnit}. Hereby the factor must <b>not</b> be
 * recalculated as {@code 1/oldFactor}, since typically reverse rates are
 * not symmetric in most cases.
 *
 * @return the matching reversed {@link ExchangeRate}, or {@code null}, if
 * the rate cannot be reversed.
 */
default ExchangeRate getReversed(ExchangeRate rate){
  ConversionQuery reverseQuery = rate.getContext().toQueryBuilder().setBaseCurrency(rate.getCurrency())
      .setTermCurrency(rate.getBaseCurrency()).build();
  if(isAvailable(reverseQuery)){
    return getExchangeRate(reverseQuery);
  }
  return null;
}
javax.money.convertExchangeRateProviderisAvailable

Javadoc

Checks if an ExchangeRate between two CurrencyUnit is available from this provider. This method should check, if a given rate is currently defined.

Popular methods of ExchangeRateProvider

  • getExchangeRate
  • getContext
    Access the ConversionContext for this ExchangeRateProvider. Each instance of ExchangeRateProvider pr
  • getCurrencyConversion

Popular in Java

  • Creating JSON documents from java classes using gson
  • addToBackStack (FragmentTransaction)
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Notification (javax.management)
  • JComboBox (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Option (scala)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now