Class CurrencyHelper

java.lang.Object
com.highdeal.currency.CurrencyHelper

public class CurrencyHelper extends Object
This Java class is a tool to work with currencies. For some of its methods, it is expected as prerequisite that the class Currency is initialized with a CurrencyBook.
  • Method Details

    • getCurrencyISOCodeOrCode

      public static final String getCurrencyISOCodeOrCode(String currencyCode)
      Returns the ISO code or the code of a currency whether the currency has an ISO code or not.

      Example

      With the following CurrencyBook:

      Currency CodeCurrency ISO Code
      EUREUR
      USDNUSD
      PNTnull
      here are some examples which shows the behavior of this method:
      currencyCodeMethod Result
      EUREUR
      USDNUSD
      PNTPNT
      UNKUNK
      nullthrows NullPointerException

      Parameters:
      currencyCode - The code of the currency for which its ISO code or its code must be returned
      Returns:
      The ISO code if specified, currencyCode otherwise i.e. if no currency has currencyCode as code or if the currency has no ISO code.
      Throws:
      NullPointerException - if the class currency is not initialized with a CurrencyBook or if currencyCode is null
    • getCurrencyISOCodeOrCode

      public static final String getCurrencyISOCodeOrCode(Currency currency)
      Returns the ISO code or the code of a currency whether the currency has an ISO code or not.
      Parameters:
      currency - The currency for which its ISO code or its code must be returned
      Returns:
      The ISO code of currency if specified, the code of the currency otherwise.
      Throws:
      NullPointerException - if currency is null.