public final class ExchangeRate extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<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.Comparable to allow sorting of multiple
exchange rates using the following sorting order;
Serializable, hereby serializing in the following
form and order:
CurrencyUnit
CurrencyUnit
ConversionContext
| Modifier and Type | Class and Description |
|---|---|
static class |
ExchangeRate.Builder
Builder for creating new instances of
ExchangeRate. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(ExchangeRate o) |
boolean |
equals(java.lang.Object obj) |
CurrencyUnit |
getBase()
Get the base (source)
CurrencyUnit. |
ConversionContext |
getConversionContext()
Access the
ConversionContext of ExchangeRate. |
java.util.List<ExchangeRate> |
getExchangeRateChain()
Access the chain of exchange rates.
|
NumberValue |
getFactor()
Access the rate's bid factor.
|
CurrencyUnit |
getTerm()
Get the term (target)
CurrencyUnit. |
int |
hashCode() |
boolean |
isDerived()
Allows to evaluate if this exchange rate is a derived exchange rate.
|
ExchangeRate.Builder |
toBuilder()
Create a
ExchangeRate.Builder based on the current rate instance. |
java.lang.String |
toString() |
public int compareTo(ExchangeRate o)
compareTo in interface java.lang.Comparable<ExchangeRate>public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final CurrencyUnit getBase()
CurrencyUnit.CurrencyUnit.public final ConversionContext getConversionContext()
ConversionContext of ExchangeRate.public final java.util.List<ExchangeRate> getExchangeRateChain()
new ExchangeRate[]{this}.public final NumberValue getFactor()
null.public final CurrencyUnit getTerm()
CurrencyUnit.CurrencyUnit.public int hashCode()
hashCode in class java.lang.Objectpublic final boolean isDerived()
true, if the chain contains more than
one rate. Direct rates, have also a chain, but with exact one rate.public ExchangeRate.Builder toBuilder()
ExchangeRate.Builder based on the current rate instance.ExchangeRate.Builder, never null.public java.lang.String toString()
toString in class java.lang.Object