public class DefaultExchangeRate extends Object implements javax.money.convert.ExchangeRate, Serializable, Comparable<javax.money.convert.ExchangeRate>
CurrencyUnit.factor matches the correct reverse
rate. But in most use cases the reverse rate either has a different rate (not
equal to the reciprocal value), or might not be defined at all. Therefore for
reversing a ExchangeRate one must access an ExchangeRateProvider and
query for the reverse rate.
The class also implements Comparable to allow sorting of multiple
exchange rates using the following sorting order;
Finally ExchangeRate is modeled as an immutable and thread safe type. Also
exchange rates are Serializable, hereby serializing in the following
form and order:
CurrencyUnit
CurrencyUnit
ConversionContext
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultExchangeRate.Builder
Builder for creating new instances of
ExchangeRate. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(javax.money.convert.ExchangeRate o) |
boolean |
equals(Object obj) |
javax.money.CurrencyUnit |
getBase()
Get the base (source)
CurrencyUnit. |
javax.money.convert.ConversionContext |
getConversionContext()
Access the
ConversionContext of ExchangeRate. |
List<javax.money.convert.ExchangeRate> |
getExchangeRateChain()
Access the chain of exchange rates.
|
javax.money.NumberValue |
getFactor()
Access the rate's bid factor.
|
javax.money.CurrencyUnit |
getTerm()
Get the term (target)
CurrencyUnit. |
int |
hashCode() |
boolean |
isDerived()
Allows to evaluate if this exchange rate is a derived exchange rate.
|
DefaultExchangeRate.Builder |
toBuilder()
Create a
DefaultExchangeRate.Builder based on the current rate instance. |
String |
toString() |
public final javax.money.convert.ConversionContext getConversionContext()
ConversionContext of ExchangeRate.getConversionContext in interface javax.money.convert.ExchangeRatepublic final javax.money.CurrencyUnit getBase()
CurrencyUnit.getBase in interface javax.money.convert.ExchangeRateCurrencyUnit.public final javax.money.CurrencyUnit getTerm()
CurrencyUnit.getTerm in interface javax.money.convert.ExchangeRateCurrencyUnit.public final javax.money.NumberValue getFactor()
getFactor in interface javax.money.convert.ExchangeRatenull.public final List<javax.money.convert.ExchangeRate> getExchangeRateChain()
getExchangeRateChain in interface javax.money.convert.ExchangeRatenew ExchangeRate[]{this}.public final boolean isDerived()
Derived exchange rates are defined by an ordered list of subconversions with intermediate steps, whereas a direct conversion is possible in one steps.
This method always returns true, if the chain contains more than
one rate. Direct rates, have also a chain, but with exact one rate.
isDerived in interface javax.money.convert.ExchangeRatepublic int compareTo(javax.money.convert.ExchangeRate o)
compareTo in interface Comparable<javax.money.convert.ExchangeRate>public DefaultExchangeRate.Builder toBuilder()
DefaultExchangeRate.Builder based on the current rate instance.DefaultExchangeRate.Builder, never null.Copyright © 2012-2014 JavaMoney. All Rights Reserved.