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


Java CompoundRateProvider类代码示例

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


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

示例1: getExchangeRateProvider

import org.javamoney.moneta.spi.CompoundRateProvider; //导入依赖的package包/类
@Override
public ExchangeRateProvider getExchangeRateProvider(ConversionQuery query) {
    Collection<String> providers = getProvidersToUse(query);
    List<ExchangeRateProvider> provInstances = new ArrayList<>();
    for (String provName : providers) {
        ExchangeRateProvider prov = this.conversionProviders.get(provName);
        if(prov==null) {
            throw new MonetaryException(
                    "Unsupported conversion/rate provider: "
                            + provName);
        }
        provInstances.add(prov);
    }
    if (provInstances.isEmpty()) {
        throw new MonetaryException("No such providers: " + query);
    }
    if (provInstances.size() == 1) {
        return provInstances.get(0);
    }
    return new CompoundRateProvider(provInstances);
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:22,代码来源:DefaultMonetaryConversionsSingletonSpi.java

示例2: testGetExchangeRateProvider_Chained

import org.javamoney.moneta.spi.CompoundRateProvider; //导入依赖的package包/类
@Test
public void testGetExchangeRateProvider_Chained() throws InterruptedException {
	ExchangeRateProvider prov = MonetaryConversions
			.getExchangeRateProvider("ECB", "IMF");
       assertNotNull(prov);
	assertEquals(CompoundRateProvider.class, prov.getClass());
	// Test rate provided by IMF (derived)
	Thread.sleep(5000L); // wait for provider to load...
	ExchangeRate r = prov.getExchangeRate(
			Monetary.getCurrency("USD"),
			Monetary.getCurrency("INR"));
       assertNotNull(r);
	assertTrue(r.isDerived());
	// Test rate provided by ECB
	r = prov.getExchangeRate(Monetary.getCurrency("EUR"),
			Monetary.getCurrency("CHF"));
       assertNotNull(r);
	assertFalse(r.isDerived());
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:20,代码来源:MonetaryConversionTest.java

示例3: getExchangeRateProvider

import org.javamoney.moneta.spi.CompoundRateProvider; //导入依赖的package包/类
@Override
public ExchangeRateProvider getExchangeRateProvider(ConversionQuery conversionQuery) {
    Collection<String> providers = getProvidersToUse(conversionQuery);
    List<ExchangeRateProvider> provInstances = new ArrayList<>();
    for (String provName : providers) {
        ExchangeRateProvider prov = Optional.ofNullable(
                this.conversionProviders.get(provName))
                .orElseThrow(
                        () -> new MonetaryException(
                                "Unsupported conversion/rate provider: "
                                        + provName));
        provInstances.add(prov);
    }
    if (provInstances.isEmpty()) {
        throw new MonetaryException("No such providers: " + conversionQuery);
    }
    if (provInstances.size() == 1) {
        return provInstances.get(0);
    }
    return new CompoundRateProvider(provInstances);
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:22,代码来源:DefaultMonetaryConversionsSingletonSpi.java

示例4: testGetExchangeRateProvider_Chained

import org.javamoney.moneta.spi.CompoundRateProvider; //导入依赖的package包/类
@Test
public void testGetExchangeRateProvider_Chained()
		throws InterruptedException {
	ExchangeRateProvider prov = MonetaryConversions
			.getExchangeRateProvider("ECB", "IMF");
	assertTrue(prov != null);
	assertEquals(CompoundRateProvider.class, prov.getClass());
	// Test rate provided by IMF (derived)
	Thread.sleep(5000L); // wait for provider to load...
	ExchangeRate r = prov.getExchangeRate(Monetary.getCurrency("USD"),
			Monetary.getCurrency("INR"));
	assertTrue(r != null);
	assertTrue(r.isDerived());
	// Test rate provided by ECB
	r = prov.getExchangeRate(Monetary.getCurrency("EUR"),
			Monetary.getCurrency("CHF"));
	assertTrue(r != null);
	assertFalse(r.isDerived());
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:20,代码来源:MonetaryConversionTest.java

示例5: testGetExchangeRateProvider_Chained

import org.javamoney.moneta.spi.CompoundRateProvider; //导入依赖的package包/类
@Test
public void testGetExchangeRateProvider_Chained()
		throws InterruptedException {
	ExchangeRateProvider prov = MonetaryConversions
			.getExchangeRateProvider("ECB", "IMF");
	assertTrue(Objects.nonNull(prov));
	assertEquals(CompoundRateProvider.class, prov.getClass());
	// Test rate provided by IMF (derived)
	Thread.sleep(5000L); // wait for provider to load...
	ExchangeRate r = prov.getExchangeRate(Monetary.getCurrency("USD"),
			Monetary.getCurrency("INR"));
	assertTrue(Objects.nonNull(r));
	assertTrue(r.isDerived());
	// Test rate provided by ECB
	r = prov.getExchangeRate(Monetary.getCurrency("EUR"),
			Monetary.getCurrency("CHF"));
	assertTrue(Objects.nonNull(r));
	assertFalse(r.isDerived());
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:20,代码来源:MonetaryConversionTest.java


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