javax.money.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 javax.money.convert.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 java., hereby serializing in the following
form and order:
javax.money.CurrencyUnit
javax.money.CurrencyUnit
javax.money.convert.ConversionContext
| Modifier and Type | Field and Description |
|---|---|
| private final CurrencyUnit | base
The base currency. |
| private final List | chain
The full chain, at least one instance long. |
| private final ConversionContext | |
| private final NumberValue | factor
The conversion factor. |
| private static final long | serialVersionUID
serialVersionUID. |
| private final CurrencyUnit | term
The terminating currency. |
| Access | Constructor and Description |
|---|---|
| pack-priv | DefaultExchangeRate(ExchangeRateBuilder
The Builder, never builder)null.Creates a new instance with a custom chain of exchange rate type, e.g. or creating derived rates. |
| Modifier and Type | Method and Description |
|---|---|
| public int | compareTo(ExchangeRate o)
Implements java. Compares this object with the specified object for order. |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public final CurrencyUnit | Returns: the basejavax..Implements javax. Get the base (source) |
| public final ConversionContext | Returns: the conversion context, never null.Implements javax. Access the |
| public final CurrencyUnit | Returns: the termjavax..Implements javax. Get the term (target) |
| public final List | Returns: the chain of rates, in case of a derived rate, this may be several instances. For a direct exchange rate, this equals tonew ExchangeRate[]{this}.Implements javax. Access the chain of exchange rates. |
| public final NumberValue | Returns: the bid factor for this exchange rate, ornull.Implements javax. Access the rate's bid factor. |
| public int | |
| public final boolean | Returns: true, if the exchange rate is derived.Overrides default javax. Allows to evaluate if this exchange rate is a derived exchange rate. |
| private void | setExchangeRateChain(List<ExchangeRate>
the chain to set. chain)Internal method to set the rate chain, which also ensure that the chain passed, when not null, contains valid elements. |
| public ExchangeRateBuilder | |
| public String |
| base | back to summary |
|---|---|
| private final CurrencyUnit base The base currency. | |
| chain | back to summary |
|---|---|
| private final List<ExchangeRate> chain The full chain, at least one instance long. | |
| conversionContext | back to summary |
|---|---|
| private final ConversionContext conversionContext | |
| factor | back to summary |
|---|---|
| private final NumberValue factor The conversion factor. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID serialVersionUID. | |
| term | back to summary |
|---|---|
| private final CurrencyUnit term The terminating currency. | |
| DefaultExchangeRate | back to summary |
|---|---|
| pack-priv DefaultExchangeRate(ExchangeRateBuilder builder) Creates a new instance with a custom chain of exchange rate type, e.g. or creating derived rates.
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(ExchangeRate o) Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| getBaseCurrency | back to summary |
|---|---|
| public final CurrencyUnit getBaseCurrency() Implements javax. Get the base (source)
| |
| getContext | back to summary |
|---|---|
| public final ConversionContext getContext() Implements javax. Access the
| |
| getCurrency | back to summary |
|---|---|
| public final CurrencyUnit getCurrency() Implements javax. Get the term (target)
| |
| getExchangeRateChain | back to summary |
|---|---|
| public final List Implements javax. Access the chain of exchange rates.
| |
| getFactor | back to summary |
|---|---|
| public final NumberValue getFactor() Implements javax. Access the rate's bid factor.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isDerived | back to summary |
|---|---|
| public final boolean isDerived() Overrides default javax. Allows to evaluate if this exchange rate is a derived exchange rate. 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
| |
| setExchangeRateChain | back to summary |
|---|---|
| private void setExchangeRateChain(List<ExchangeRate> chain) Internal method to set the rate chain, which also ensure that the chain passed, when not null, contains valid elements.
| |
| toBuilder | back to summary |
|---|---|
| public ExchangeRateBuilder toBuilder() Create a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |