use of org.javamoney.moneta.spi.CompoundRateProvider in project jsr354-ri-bp by JavaMoney.
the class DefaultMonetaryConversionsSingletonSpi method getExchangeRateProvider.
@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);
}
use of org.javamoney.moneta.spi.CompoundRateProvider in project jsr354-ri-bp by JavaMoney.
the class DefaultMonetaryConversionsSingletonSpi method getExchangeRateProvider.
@Override
public ExchangeRateProvider getExchangeRateProvider(String... providers) {
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.size() == 1) {
return provInstances.get(0);
}
return new CompoundRateProvider(provInstances);
}
use of org.javamoney.moneta.spi.CompoundRateProvider in project jsr354-ri by JavaMoney.
the class DefaultMonetaryConversionsSingletonSpi method getExchangeRateProvider.
@Override
public ExchangeRateProvider getExchangeRateProvider(String... providers) {
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.size() == 1) {
return provInstances.get(0);
}
return new CompoundRateProvider(provInstances);
}
use of org.javamoney.moneta.spi.CompoundRateProvider in project jsr354-ri by JavaMoney.
the class DefaultMonetaryConversionsSingletonSpi method getExchangeRateProvider.
@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);
}
Aggregations