Package org.javamoney.moneta.convert
Class ExchangeRateBuilder
java.lang.Object
org.javamoney.moneta.convert.ExchangeRateBuilder
Builder for creating new instances of
ExchangeRate. Note that
instances of this class are not thread-safe.- Author:
- Anatole Tresch, Werner Keil
-
Constructor Summary
ConstructorsConstructorDescriptionExchangeRateBuilder(String provider, RateType rateType) Sets the exchange rate typeExchangeRateBuilder(ConversionContext context) Sets the exchange rate typeSets the exchange rate type -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new instance ofExchangeRate.setBase(CurrencyUnit base) Sets the baseCurrencyUnitsetContext(ConversionContext conversionContext) Sets the provider to be applied.setFactor(NumberValue factor) Sets the conversion factor, as the factorbase * factor = target.setRate(ExchangeRate rate) Initialize theExchangeRateBuilderwith anExchangeRate.setRateChain(List<ExchangeRate> exchangeRates) Sets theExchangeRatechain.setRateChain(ExchangeRate... exchangeRates) Sets theExchangeRatechain.setTerm(CurrencyUnit term) Sets the terminating (target)CurrencyUnittoString()
-
Constructor Details
-
ExchangeRateBuilder
Sets the exchange rate type- Parameters:
rateType- theRateTypecontained
-
ExchangeRateBuilder
Sets the exchange rate type- Parameters:
context- theConversionContextto be applied
-
ExchangeRateBuilder
Sets the exchange rate type- Parameters:
rate- theExchangeRateto be applied
-
-
Method Details
-
setBase
Sets the baseCurrencyUnit- Parameters:
base- to base (source)CurrencyUnitto be applied- Returns:
- the builder instance
-
setTerm
Sets the terminating (target)CurrencyUnit- Parameters:
term- to terminatingCurrencyUnitto be applied- Returns:
- the builder instance
-
setRateChain
Sets theExchangeRatechain.- Parameters:
exchangeRates- theExchangeRatechain to be applied- Returns:
- the builder instance
-
setRateChain
Sets theExchangeRatechain.- Parameters:
exchangeRates- theExchangeRatechain to be applied- Returns:
- the builder instance
-
setFactor
Sets the conversion factor, as the factorbase * factor = target.- Parameters:
factor- the factor.- Returns:
- The builder instance.
-
setContext
Sets the provider to be applied.- Parameters:
conversionContext- theConversionContext, not null.- Returns:
- The builder.
-
build
Builds a new instance ofExchangeRate.- Returns:
- a new instance of
ExchangeRate. - Throws:
IllegalArgumentException- if the rate could not be built.
-
setRate
Initialize theExchangeRateBuilderwith anExchangeRate. This is useful for creating a new rate, reusing some properties from an existing one.- Parameters:
rate- the base rate- Returns:
- the Builder, for chaining.
-
toString
-