Top Description Fields Constructors Methods
org.javamoney.moneta.convert

public Class ExchangeRateBuilder

extends Object
Class Inheritance
Imports
javax.money.CurrencyUnit, .NumberValue, javax.money.convert.ConversionContext, .ExchangeRate, .RateType, java.util.ArrayList, .Arrays, .List, .Objects

Builder for creating new instances of javax.money.convert.ExchangeRate. Note that instances of this class are not thread-safe.
Authors
Anatole Tresch, Werner Keil

Field Summary

Modifier and TypeField and Description
pack-priv CurrencyUnit
base

The base (source) currency.

pack-priv ConversionContext
pack-priv NumberValue
factor

The conversion factor.

pack-priv List<ExchangeRate>
rateChain

The chain of involved rates.

pack-priv CurrencyUnit
term

The term (target) currency.

Constructor Summary

AccessConstructor and Description
public
ExchangeRateBuilder(String provider, RateType rateType)

Sets the exchange rate type

public
ExchangeRateBuilder(ConversionContext context)

Sets the exchange rate type

public
ExchangeRateBuilder(ExchangeRate rate)

Sets the exchange rate type

Method Summary

Modifier and TypeMethod and Description
public ExchangeRate

Returns:

a new instance of javax.money.convert.ExchangeRate.
build
()

Builds a new instance of javax.money.convert.ExchangeRate.

public ExchangeRateBuilder

Returns:

the builder instance
setBase
(CurrencyUnit
to base (source) javax.money.CurrencyUnit to be applied
base
)

Sets the base javax.money.CurrencyUnit

public ExchangeRateBuilder

Returns:

The builder.
setContext
(ConversionContext conversionContext)

Sets the provider to be applied.

public ExchangeRateBuilder

Returns:

The builder instance.
setFactor
(NumberValue
the factor.
factor
)

Sets the conversion factor, as the factor base * factor = target.

public ExchangeRateBuilder

Returns:

the Builder, for chaining.
setRate
(ExchangeRate
the base rate
rate
)

Initialize the ExchangeRateBuilder with an javax.money.convert.ExchangeRate.

public ExchangeRateBuilder

Returns:

the builder instance
setRateChain
(ExchangeRate...
the javax.money.convert.ExchangeRate chain to be applied
exchangeRates
)

Sets the javax.money.convert.ExchangeRate chain.

public ExchangeRateBuilder

Returns:

the builder instance
setRateChain
(List<ExchangeRate>
the javax.money.convert.ExchangeRate chain to be applied
exchangeRates
)

Sets the javax.money.convert.ExchangeRate chain.

public ExchangeRateBuilder

Returns:

the builder instance
setTerm
(CurrencyUnit
to terminating javax.money.CurrencyUnit to be applied
term
)

Sets the terminating (target) javax.money.CurrencyUnit

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

baseback to summary
pack-priv CurrencyUnit base

The base (source) currency.

conversionContextback to summary
pack-priv ConversionContext conversionContext

The javax.money.convert.ConversionContext.

factorback to summary
pack-priv NumberValue factor

The conversion factor.

rateChainback to summary
pack-priv List<ExchangeRate> rateChain

The chain of involved rates.

termback to summary
pack-priv CurrencyUnit term

The term (target) currency.

Constructor Detail

ExchangeRateBuilderback to summary
public ExchangeRateBuilder(String provider, RateType rateType)

Sets the exchange rate type

Parameters
rateType:RateType

the javax.money.convert.RateType contained

ExchangeRateBuilderback to summary
public ExchangeRateBuilder(ConversionContext context)

Sets the exchange rate type

Parameters
context:ConversionContext

the javax.money.convert.ConversionContext to be applied

ExchangeRateBuilderback to summary
public ExchangeRateBuilder(ExchangeRate rate)

Sets the exchange rate type

Parameters
rate:ExchangeRate

the javax.money.convert.ExchangeRate to be applied

Method Detail

buildback to summary
public ExchangeRate build()

Builds a new instance of javax.money.convert.ExchangeRate.

Returns:ExchangeRate

a new instance of javax.money.convert.ExchangeRate.

Exceptions
IllegalArgumentException:
if the rate could not be built.
setBaseback to summary
public ExchangeRateBuilder setBase(CurrencyUnit base)

Sets the base javax.money.CurrencyUnit

Parameters
base:CurrencyUnit

to base (source) javax.money.CurrencyUnit to be applied

Returns:ExchangeRateBuilder

the builder instance

setContextback to summary
public ExchangeRateBuilder setContext(ConversionContext conversionContext)

Sets the provider to be applied.

Parameters
conversionContext:ConversionContext

the javax.money.convert.ConversionContext, not null.

Returns:ExchangeRateBuilder

The builder.

setFactorback to summary
public ExchangeRateBuilder setFactor(NumberValue factor)

Sets the conversion factor, as the factor base * factor = target.

Parameters
factor:NumberValue

the factor.

Returns:ExchangeRateBuilder

The builder instance.

setRateback to summary
public ExchangeRateBuilder setRate(ExchangeRate rate)

Initialize the ExchangeRateBuilder with an javax.money.convert.ExchangeRate. This is useful for creating a new rate, reusing some properties from an existing one.

Parameters
rate:ExchangeRate

the base rate

Returns:ExchangeRateBuilder

the Builder, for chaining.

setRateChainback to summary
public ExchangeRateBuilder setRateChain(ExchangeRate... exchangeRates)

Sets the javax.money.convert.ExchangeRate chain.

Parameters
exchangeRates:ExchangeRate[]

the javax.money.convert.ExchangeRate chain to be applied

Returns:ExchangeRateBuilder

the builder instance

setRateChainback to summary
public ExchangeRateBuilder setRateChain(List<ExchangeRate> exchangeRates)

Sets the javax.money.convert.ExchangeRate chain.

Parameters
exchangeRates:List<ExchangeRate>

the javax.money.convert.ExchangeRate chain to be applied

Returns:ExchangeRateBuilder

the builder instance

setTermback to summary
public ExchangeRateBuilder setTerm(CurrencyUnit term)

Sets the terminating (target) javax.money.CurrencyUnit

Parameters
term:CurrencyUnit

to terminating javax.money.CurrencyUnit to be applied

Returns:ExchangeRateBuilder

the builder instance

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override