Class Currency

java.lang.Object
org.episteme.core.measure.StandardUnit<Money>
org.episteme.social.economics.money.Currency
All Implemented Interfaces:
Serializable, Unit<Money>, Commented, ComprehensiveIdentification, Identified<Identification>, Named

public class Currency extends StandardUnit<Money> implements ComprehensiveIdentification
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 Details

    • AUD

      public static final Currency AUD
      Australian Dollar (A$)
    • CAD

      public static final Currency CAD
      Canadian Dollar (C$)
    • CNY

      public static final Currency CNY
      Chinese Yuan (Â¥)
    • EUR

      public static final Currency EUR
      Euro (€)
    • GBP

      public static final Currency GBP
      British Pound (£)
    • HKD

      public static final Currency HKD
      Hong Kong Dollar (HK$)
    • INR

      public static final Currency INR
      Indian Rupee (₹)
    • JPY

      public static final Currency JPY
      Japanese Yen (Â¥)
    • KRW

      public static final Currency KRW
      Korean Republic Won (â‚©)
    • RUB

      public static final Currency RUB
      Russian Ruble (₽)
    • CHF

      public static final Currency CHF
      Swiss Franc (CHF)
    • TWD

      public static final Currency TWD
      Taiwanese dollar (NT$)
    • USD

      public static final Currency USD
      United State dollar ($)
    • BTC

      public static final Currency BTC
      Bitcoin (â‚¿) - Conceptual
  • Constructor Details

    • Currency

      public Currency(String name, String code, String symbol, int fractionalDigits)
      Creates a currency with full details.
      Parameters:
      name - the currency name
      code - the ISO-4217 code
      symbol - the currency symbol
      fractionalDigits - the number of fractional digits
    • Currency

      public Currency(String code, String symbol, int fractionalDigits)
      Creates the currency unit for the given currency code.
      Parameters:
      code - the ISO-4217 code of the currency.
      symbol - the currency symbol.
      fractionalDigits - the number of fractional digits.
    • Currency

      public Currency(String code)
      Creates a currency unit with default settings.
  • Method Details

    • of

      public static Currency of(String code)
    • getCode

      public String getCode()
      Returns the currency code for this currency.
      Returns:
      the ISO-4217 code.
    • getSymbol

      public String getSymbol()
      Returns the currency symbol.
      Specified by:
      getSymbol in interface Unit<Money>
      Overrides:
      getSymbol in class StandardUnit<Money>
      Returns:
      the unit symbol
    • getFractionalDigits

      public int getFractionalDigits()
      Returns the number of fractional digits for this currency.
    • getId

      public Identification getId()
      Description copied from interface: Identified
      Returns the unique identifier of this entity.
      Specified by:
      getId in interface Identified<Identification>
      Returns:
      the identifier
    • getTraits

      public Map<String,Object> getTraits()
      Description copied from interface: ComprehensiveIdentification
      Returns the traits map for this entity.
      Specified by:
      getTraits in interface Commented
      Specified by:
      getTraits in interface ComprehensiveIdentification
      Returns:
      the traits map
    • setReferenceCurrency

      public static void setReferenceCurrency(Currency currency)
      Sets the reference currency.
    • getReferenceCurrency

      public static Currency getReferenceCurrency()
    • setExchangeRate

      public void setExchangeRate(Real refAmount)
      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

      public Real getExchangeRate()
      Returns the exchange rate of this currency.
    • getConverterTo

      public UnitConverter getConverterTo(Unit<Money> targetUnit)
      Description copied from interface: Unit
      Returns a converter to convert values from this unit to the target unit.

      Both units must have compatible dimensions.

      Specified by:
      getConverterTo in interface Unit<Money>
      Overrides:
      getConverterTo in class StandardUnit<Money>
      Parameters:
      targetUnit - the target unit
      Returns:
      a converter from this unit to the target
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class StandardUnit<Money>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class StandardUnit<Money>