public final class TestCurrency extends java.lang.Object implements CurrencyUnit, java.io.Serializable, java.lang.Comparable<CurrencyUnit>
CurrencyUnit
interface using the
JDK's Currency
.Modifier and Type | Class and Description |
---|---|
static class |
TestCurrency.Builder |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ISO_NAMESPACE
The predefined name space for ISO 4217 currencies, similar to
Currency . |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(CurrencyUnit currency) |
static java.util.Collection<CurrencyUnit> |
getAllMatching(java.lang.String expression) |
int |
getCashRounding() |
java.lang.String |
getCurrencyCode()
Gets the unique currency code, the effective code depends on the
currency.
|
int |
getDefaultFractionDigits()
Gets the number of fractional digits typically used by this currency.
|
int |
getNumericCode()
Gets a numeric currency code. within the ISO-4217 name space, this equals
to the ISO numeric code.
|
static CurrencyUnit |
of(java.util.Currency currency) |
static CurrencyUnit |
of(java.lang.String currencyCode) |
java.lang.String |
toString() |
public static final java.lang.String ISO_NAMESPACE
Currency
.public static CurrencyUnit of(java.util.Currency currency)
public static CurrencyUnit of(java.lang.String currencyCode)
public java.lang.String getCurrencyCode()
CurrencyUnit
Since each currency is identified by this code, the currency code is
required to be defined for every CurrencyUnit
and not
null
or empty.
For ISO codes the 3-letter ISO code should be returned. For non ISO currencies no constraints are defined.
getCurrencyCode
in interface CurrencyUnit
null
. For ISO-4217 this this
will be the three letter ISO-4217 code. However, alternate
currencies can have different codes. Also there is no constraint
about the formatting of alternate codes, despite the fact that
the currency codes must be unique.public int getNumericCode()
CurrencyUnit
The numeric code is an optional alternative to the standard currency code. If defined, the numeric code is required to be unique.
This method matches the API of Currency
.
getNumericCode
in interface CurrencyUnit
public int getDefaultFractionDigits()
CurrencyUnit
Different currencies have different numbers of fractional digits by default. For example, 'GBP' has 2 fractional digits, but 'JPY' has zero. virtual currencies or those with no applicable fractional are indicated by -1.
This method matches the API of Currency
.
getDefaultFractionDigits
in interface CurrencyUnit
public int getCashRounding()
public int compareTo(CurrencyUnit currency)
compareTo
in interface java.lang.Comparable<CurrencyUnit>
public java.lang.String toString()
toString
in class java.lang.Object
public static java.util.Collection<CurrencyUnit> getAllMatching(java.lang.String expression)