public class TestExchangeRate 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 |
TestExchangeRate.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 |
getBaseCurrency()
Get the base (source)
CurrencyUnit. |
javax.money.convert.ConversionContext |
getContext()
Access the
ConversionContext of ExchangeRate. |
javax.money.CurrencyUnit |
getCurrency()
Get the term (target)
CurrencyUnit. |
List<javax.money.convert.ExchangeRate> |
getExchangeRateChain()
Access the chain of exchange rates.
|
javax.money.NumberValue |
getFactor()
Access the rate's bid factor.
|
int |
hashCode() |
boolean |
isDerived()
Allows to evaluate if this exchange rate is a derived exchange rate.
|
TestExchangeRate.Builder |
toBuilder()
Create a
TestExchangeRate.Builder based on the current rate instance. |
String |
toString() |
public final javax.money.convert.ConversionContext getContext()
ConversionContext of ExchangeRate.getContext in interface javax.money.convert.ExchangeRatepublic final javax.money.CurrencyUnit getBaseCurrency()
CurrencyUnit.getBaseCurrency in interface javax.money.convert.ExchangeRateCurrencyUnit.public final javax.money.CurrencyUnit getCurrency()
CurrencyUnit.getCurrency in interface javax.money.convert.ExchangeRategetCurrency in interface javax.money.CurrencySupplierCurrencyUnit.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()
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 TestExchangeRate.Builder toBuilder()
TestExchangeRate.Builder based on the current rate instance.TestExchangeRate.Builder, never null.Copyright © 2012-2015 JavaMoney. All Rights Reserved.