当前位置: 首页>>代码示例>>Java>>正文


Java CurrencyQueryBuilder类代码示例

本文整理汇总了Java中javax.money.CurrencyQueryBuilder的典型用法代码示例。如果您正苦于以下问题:Java CurrencyQueryBuilder类的具体用法?Java CurrencyQueryBuilder怎么用?Java CurrencyQueryBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CurrencyQueryBuilder类属于javax.money包,在下文中一共展示了CurrencyQueryBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrency

import javax.money.CurrencyQueryBuilder; //导入依赖的package包/类
/**
 * Access a new instance based on the currency code. Currencies are
 * available as provided by {@link javax.money.spi.CurrencyProviderSpi} instances registered
 * with the {@link javax.money.spi.Bootstrap}.
 *
 * @param currencyCode the ISO currency code, not {@code null}.
 * @param providers    the (optional) specification of providers to consider. If not set (empty) the providers
 *                     as defined by #getDefaultRoundingProviderChain() should be used.
 * @return the corresponding {@link javax.money.CurrencyUnit} instance.
 * @throws javax.money.UnknownCurrencyException if no such currency exists.
 */
public CurrencyUnit getCurrency(String currencyCode, String... providers) {
    Objects.requireNonNull(currencyCode, "Currency Code may not be null");
    Collection<CurrencyUnit> found =
            getCurrencies(CurrencyQueryBuilder.of().setCurrencyCodes(currencyCode).setProviderNames(providers).build());
    if (found.isEmpty()) {
        throw new UnknownCurrencyException(currencyCode);
    }
    if (found.size() > 1) {
        throw new MonetaryException("Ambiguous CurrencyUnit for code: " + currencyCode + ": " + found);
    }
    return found.iterator().next();
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:24,代码来源:BaseMonetaryCurrenciesSingletonSpi.java

示例2: main

import javax.money.CurrencyQueryBuilder; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
    ConsoleUtils.printDetails(Monetary.getCurrency("CHF"));

    Monetary.getCurrencies(CurrencyQueryBuilder.of().setProviderNames("ConfigurableCurrencyUnitProvider").build()).forEach(
            ConsoleUtils::printDetails
    );

    CurrencyUnitBuilder.of("GeeCon", "GeeCon-Conference").build(true);
    Monetary.getCurrencies(CurrencyQueryBuilder.of().setProviderNames("ConfigurableCurrencyUnitProvider").build()).forEach(
            ConsoleUtils::printDetails
    );
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:16,代码来源:CurrenciesAccess.java

示例3: main

import javax.money.CurrencyQueryBuilder; //导入依赖的package包/类
public static void main(String[] args) {
    ConsoleUtils.printDetails(
            CurrencyUnitBuilder.of("GeeCoin", "BuildingCurrenciesExample").setCurrencyCode("GCC").setDefaultFractionDigits(2).build());
    Monetary.getCurrencies(CurrencyQueryBuilder.of().setProviderNames("ConfigurableCurrencyUnitProvider").build()).forEach(
            ConsoleUtils::printDetails
    );
    ConsoleUtils.printDetails(
            CurrencyUnitBuilder.of("GeeCoin", "BuildingCurrenciesExample").setCurrencyCode("GCC").setDefaultFractionDigits(2).build(true));
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:10,代码来源:CurrenciesUseBuilder.java

示例4: getNamespaceQuery

import javax.money.CurrencyQueryBuilder; //导入依赖的package包/类
@Override
public CurrencyQuery getNamespaceQuery(String targetNamespace){
    return CurrencyQueryBuilder.of().set(CurrencyMappingQuerySelector.NAMESPACE)
            .set("targetNamespace", targetNamespace).build();
}
 
开发者ID:JavaMoney,项目名称:javamoney-lib,代码行数:6,代码来源:DefaultCurrencyMappingsSingletonSpi.java

示例5: getCurrencies

import javax.money.CurrencyQueryBuilder; //导入依赖的package包/类
/**
 * Provide access to all currently known currencies.
 *
 * @param locale    the target {@link java.util.Locale}, typically representing an ISO country,
 *                  not {@code null}.
 * @param providers the (optional) specification of providers to consider. If not set (empty) the providers
 *                  as defined by #getDefaultRoundingProviderChain() should be used.
 * @return a collection of all known currencies, never null.
 */
public Set<CurrencyUnit> getCurrencies(Locale locale, String... providers) {
    return getCurrencies(CurrencyQueryBuilder.of().setCountries(locale).setProviderNames(providers).build());
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:13,代码来源:BaseMonetaryCurrenciesSingletonSpi.java

示例6: isCurrencyAvailable

import javax.money.CurrencyQueryBuilder; //导入依赖的package包/类
/**
 * Allows to check if a {@link javax.money.CurrencyUnit} instance is defined, i.e.
 * accessible from {@link BaseMonetaryCurrenciesSingletonSpi#getCurrency(String, String...)}.
 *
 * @param code      the currency code, not {@code null}.
 * @param providers the (optional) specification of providers to consider. If not set (empty) the providers
 *                  as defined by #getDefaultRoundingProviderChain() should be used.
 * @return {@code true} if {@link BaseMonetaryCurrenciesSingletonSpi#getCurrency(String, String...)}
 * would return a result for the given code.
 */
public boolean isCurrencyAvailable(String code, String... providers) {
    return !getCurrencies(CurrencyQueryBuilder.of().setCurrencyCodes(code).setProviderNames(providers).build())
            .isEmpty();
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:15,代码来源:BaseMonetaryCurrenciesSingletonSpi.java

示例7: getMappingQuery

import javax.money.CurrencyQueryBuilder; //导入依赖的package包/类
/**
 * This method maps the given {@link CurrencyUnit} to another
 * {@link CurrencyUnit} with the given target namespace.
 *
 * @param currencyUnit    The source unit, never {@code null}.
 * @param targetNamespace the target namespace, never {@code null}.
 * @return The mapped {@link CurrencyUnit}, or {@code null}.
 */
@Override
public CurrencyQuery getMappingQuery(CurrencyUnit currencyUnit, String targetNamespace){
    return CurrencyQueryBuilder.of().set(CurrencyMappingQuerySelector.MAPPING).set(currencyUnit, CurrencyUnit.class)
            .set("targetNamespace", targetNamespace).build();
}
 
开发者ID:JavaMoney,项目名称:javamoney-lib,代码行数:14,代码来源:DefaultCurrencyMappingsSingletonSpi.java


注:本文中的javax.money.CurrencyQueryBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。