Class Currency
- All Implemented Interfaces:
Serializable, Unit<Money>, Commented, ComprehensiveIdentification, Identified<Identification>, Named
Represents a currency as a unit of monetary measurement.
Currencies are special units where conversions depend on exchange rates
that can change dynamically. Quantities stated in Currency are typically
instances of Money.
* @see ISO 4217
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CurrencyAustralian Dollar (A$)static final CurrencyBitcoin (₿) - Conceptualstatic final CurrencyCanadian Dollar (C$)static final CurrencySwiss Franc (CHF)static final CurrencyChinese Yuan (¥)static final CurrencyEuro (€)static final CurrencyBritish Pound (£)static final CurrencyHong Kong Dollar (HK$)static final CurrencyIndian Rupee (₹)static final CurrencyJapanese Yen (¥)static final CurrencyKorean Republic Won (₩)static final CurrencyRussian Ruble (₽)static final CurrencyTaiwanese dollar (NT$)static final CurrencyUnited State dollar ($) -
Constructor Summary
ConstructorsConstructorDescriptionCreates a currency unit with default settings.Creates the currency unit for the given currency code.Creates a currency with full details. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetCode()Returns the currency code for this currency.getConverterTo(Unit<Money> targetUnit) Returns a converter to convert values from this unit to the target unit.Returns the exchange rate of this currency.intReturns the number of fractional digits for this currency.getId()Returns the unique identifier of this entity.static CurrencyReturns the currency symbol.Returns the traits map for this entity.inthashCode()static CurrencyvoidsetExchangeRate(double refAmount) voidsetExchangeRate(Real refAmount) Sets the exchange rate of this currency relative to the reference currency.static voidsetReferenceCurrency(Currency currency) Sets the reference currency.Methods inherited from class StandardUnit
add, divide, divide, getDimension, getName, isBaseUnit, multiply, multiply, pow, sqrt, toStringMethods inherited from interface Commented
getComments, getTrait, setCommentsMethods inherited from interface ComprehensiveIdentification
getName, getTrait, setName, setTraitMethods inherited from interface Unit
asType, getConverterFrom, inverse, isCompatible
-
Field Details
-
AUD
Australian Dollar (A$) -
CAD
Canadian Dollar (C$) -
CNY
Chinese Yuan (Â¥) -
EUR
Euro (€) -
GBP
British Pound (£) -
HKD
Hong Kong Dollar (HK$) -
INR
Indian Rupee (₹) -
JPY
Japanese Yen (Â¥) -
KRW
Korean Republic Won (â‚©) -
RUB
Russian Ruble (₽) -
CHF
Swiss Franc (CHF) -
TWD
Taiwanese dollar (NT$) -
USD
United State dollar ($) -
BTC
Bitcoin (â‚¿) - Conceptual
-
-
Constructor Details
-
Currency
-
Currency
-
Currency
Creates a currency unit with default settings.
-
-
Method Details
-
of
-
getCode
-
getSymbol
-
getFractionalDigits
public int getFractionalDigits()Returns the number of fractional digits for this currency. -
getId
Description copied from interface:IdentifiedReturns the unique identifier of this entity.- Specified by:
getIdin interfaceIdentified<Identification>- Returns:
- the identifier
-
getTraits
Description copied from interface:ComprehensiveIdentificationReturns the traits map for this entity.- Specified by:
getTraitsin interfaceCommented- Specified by:
getTraitsin interfaceComprehensiveIdentification- Returns:
- the traits map
-
setReferenceCurrency
Sets the reference currency. -
getReferenceCurrency
-
setExchangeRate
Sets the exchange rate of this currency relative to the reference currency.- Parameters:
refAmount- value of 1 unit of this currency in reference currency.
-
setExchangeRate
public void setExchangeRate(double refAmount) -
getExchangeRate
Returns the exchange rate of this currency. -
getConverterTo
Description copied from interface:UnitReturns a converter to convert values from this unit to the target unit.Both units must have compatible dimensions.
- Specified by:
getConverterToin interfaceUnit<Money>- Overrides:
getConverterToin classStandardUnit<Money>- Parameters:
targetUnit- the target unit- Returns:
- a converter from this unit to the target
-
equals
- Overrides:
equalsin classStandardUnit<Money>
-
hashCode
public int hashCode()- Overrides:
hashCodein classStandardUnit<Money>
-