本文整理汇总了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);
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}