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


Java ConversionContext.of方法代码示例

本文整理汇总了Java中javax.money.convert.ConversionContext.of方法的典型用法代码示例。如果您正苦于以下问题:Java ConversionContext.of方法的具体用法?Java ConversionContext.of怎么用?Java ConversionContext.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.money.convert.ConversionContext的用法示例。


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

示例1: getCurrencyConversion

import javax.money.convert.ConversionContext; //导入方法依赖的package包/类
@Override
public CurrencyConversion getCurrencyConversion(ConversionQuery conversionQuery) {
    if (getContext().getRateTypes().size() == 1) {
        return new LazyBoundCurrencyConversion(conversionQuery, this, ConversionContext
                .of(getContext().getProviderName(), getContext().getRateTypes().iterator().next()));
    }
    return new LazyBoundCurrencyConversion(conversionQuery, this,
            ConversionContext.of(getContext().getProviderName(), RateType.ANY));
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:10,代码来源:AbstractRateProvider.java

示例2: getExchangeContext

import javax.money.convert.ConversionContext; //导入方法依赖的package包/类
@Override
protected ConversionContext getExchangeContext(String key) {
	int scale = getScale(key);
       if(scale < 0) {
         return ConversionContext.of(this.context.getProviderName(), RateType.HISTORIC);
       } else {
       	return ConversionContext.of(this.context.getProviderName(), RateType.HISTORIC).toBuilder().set(KEY_SCALE, scale).build();
       }
}
 
开发者ID:JavaMoney,项目名称:javamoney-lib,代码行数:10,代码来源:YahooAbstractRateProvider.java

示例3: getExchangeContext

import javax.money.convert.ConversionContext; //导入方法依赖的package包/类
protected ConversionContext getExchangeContext(String key) {
	int scale = getScale(key);
       if(scale < 0) {
         return ConversionContext.of(this.context.getProviderName(), RateType.HISTORIC);
       } else {
       	return ConversionContext.of(this.context.getProviderName(), RateType.HISTORIC).toBuilder().set(KEY_SCALE, scale).build();
       }
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:9,代码来源:AbstractRateProvider.java

示例4: getCurrencyConversion

import javax.money.convert.ConversionContext; //导入方法依赖的package包/类
@Override
public CurrencyConversion getCurrencyConversion(ConversionQuery conversionQuery) {
    return new LazyBoundCurrencyConversion(conversionQuery, this, ConversionContext
            .of(getContext().getProviderName(), getContext().getRateTypes().iterator().next()));
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:6,代码来源:BaseXChangeExchangeRateProvider.java

示例5: getExchangeRate

import javax.money.convert.ConversionContext; //导入方法依赖的package包/类
@Override
public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) {
    try {
        if (loadLock.await(30, TimeUnit.SECONDS)) {
            if (currencyToSdr.isEmpty()) {
                return null;
            }
            if (!isAvailable(conversionQuery)) {
                return null;
            }
            CurrencyUnit base = conversionQuery.getBaseCurrency();
            CurrencyUnit term = conversionQuery.getCurrency();
            Calendar timestamp = conversionQuery.get(Calendar.class);
            if (timestamp == null) {
                timestamp = conversionQuery.get(GregorianCalendar.class);
            }
            ExchangeRate rate1;
            ExchangeRate rate2;
            LocalDate localDate;
            if (timestamp == null) {
                localDate = LocalDate.yesterday();
                rate1 = lookupRate(currencyToSdr.get(base), localDate);
                rate2 = lookupRate(sdrToCurrency.get(term), localDate);
                if(rate1==null || rate2==null){
                    localDate = LocalDate.beforeDays(2);
                }
                rate1 = lookupRate(currencyToSdr.get(base), localDate);
                rate2 = lookupRate(sdrToCurrency.get(term), localDate);
                if(rate1==null || rate2==null){
                    localDate = LocalDate.beforeDays(3);
                    rate1 = lookupRate(currencyToSdr.get(base), localDate);
                    rate2 = lookupRate(sdrToCurrency.get(term), localDate);
                }
            }
            else{
                localDate = LocalDate.from(timestamp);
                rate1 = lookupRate(currencyToSdr.get(base), localDate);
                rate2 = lookupRate(sdrToCurrency.get(term), localDate);
            }
            if(rate1==null || rate2==null){
                return null;
            }
            if (base.equals(SDR)) {
                return rate2;
            } else if (term.equals(SDR)) {
                return rate1;
            }
            ExchangeRateBuilder builder =
                    new ExchangeRateBuilder(ConversionContext.of(CONTEXT.getProviderName(), RateType.HISTORIC));
            builder.setBase(base);
            builder.setTerm(term);
            builder.setFactor(multiply(rate1.getFactor(), rate2.getFactor()));
            builder.setRateChain(rate1, rate2);
            return builder.build();
        }else{
            // Lets wait for a successful load only once, then answer requests as data is present.
            loadLock.countDown();
            throw new MonetaryException("Failed to load currency conversion data: " + loadState);
        }
    }
    catch(InterruptedException e){
        throw new MonetaryException("Failed to load currency conversion data: Load task has been interrupted.", e);
    }
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:65,代码来源:IMFRateProvider.java

示例6: ExchangeRateBuilder

import javax.money.convert.ConversionContext; //导入方法依赖的package包/类
/**
 * Sets the exchange rate type
 *
 * @param rateType the {@link javax.money.convert.RateType} contained
 */
public ExchangeRateBuilder(String provider, RateType rateType) {
    this(ConversionContext.of(provider, rateType));
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:9,代码来源:ExchangeRateBuilder.java


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