Enum CurrencyCode

    • Field Detail

      • numericMap

        private static final java.util.Map<java.lang.Integer,​CurrencyCode> numericMap
      • name

        private final java.lang.String name
      • numeric

        private final int numeric
      • minorUnit

        private final int minorUnit
      • countryList

        private final java.util.List<CountryCode> countryList
    • Constructor Detail

      • CurrencyCode

        private CurrencyCode​(java.lang.String name,
                             int numeric,
                             int minorUnit,
                             CountryCode... countries)
    • Method Detail

      • values

        public static CurrencyCode[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CurrencyCode c : CurrencyCode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CurrencyCode valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getName

        public java.lang.String getName()
        Get the currency name.
        Returns:
        The currency name.
      • getNumeric

        public int getNumeric()
        Get the ISO 4217 numeric code.
        Returns:
        The ISO 4217 numeric code.
      • getMinorUnit

        public int getMinorUnit()
        Get the minor unit.
        Returns:
        The minor unit. -1 means N.A.
      • getCountryList

        public java.util.List<CountryCode> getCountryList()
        Get the list of countries using this currency.
        Returns:
        The list of countries using this currency.
      • isFund

        public boolean isFund()
        Check if this currency code represents a fund.

        CurrencyCode instances listed below return true.

        • BOV Mvdol
        • CHE WIR EUro
        • CHW WIR Franc
        • CLF Unidad de Fomento
        • COU Unidad de Valor Real
        • MXV Mexican Unidad de Inversion (UDI)
        • USN US Dollar (Next day)
        • USS US Dollar (Same day)
        • UYI Uruguay Peso en Unidades
        Returns:
        True if this currency code represents a fund.
      • isPreciousMetal

        public boolean isPreciousMetal()
        Check if this currency code represents a precious metal.

        CurrencyCode instances listed below return true.

        Returns:
        True if this currency code represents a precious metal.
      • getCurrency

        public java.util.Currency getCurrency()
        Get the Currency instance that corresponds to this currency code.

        This method is an alias of Currency.getInstance(this.name()). The only difference is that this method returns null when Currency.getInstance(String) throws IllegalArgumentException.

        Returns:
        A Currency instance, or null if this ISO 4217 code is not supported by the implementation of Currency.getInstance(String).
        See Also:
        Currency.getInstance(String)
      • getByCode

        public static CurrencyCode getByCode​(java.lang.String code)
        Get a CurrencyCode that corresponds to the given ISO 4217 alpha-3 code.

        This method calls getByCode(code, true). Note that the behavior has changed since the version 1.13. In the older versions, this method was an alias of getByCode(code, false).

        Parameters:
        code - ISO 4217 alpha-3 code. When "UNDEFINED" is given, CurrencyCode.UNDEFINED is returned.
        Returns:
        A CurrencyCode instance, or null if not found.
        See Also:
        getByCode(String, boolean)
      • getByCodeIgnoreCase

        public static CurrencyCode getByCodeIgnoreCase​(java.lang.String code)
        Get a CurrencyCode that corresponds to the given ISO 4217 alpha-3 code.

        This method calls getByCode(code, false).

        Parameters:
        code - ISO 4217 alpha-3 code. Or "UNDEFINED" (case insensitive).
        Returns:
        A CurrencyCode instance, or null if not found.
        Since:
        1.13
        See Also:
        getByCode(String, boolean)
      • getByCode

        public static CurrencyCode getByCode​(java.lang.String code,
                                             boolean caseSensitive)
        Get a CurrencyCode that corresponds to the given ISO 4217 alpha-3 code.
        Parameters:
        code - ISO 4217 alpha-3 code. Or "UNDEFINED" (its case sensitivity depends on the value of caseSensitive).
        caseSensitive - If true, the given code should consist of upper-case letters only. If false, this method internally canonicalizes the given code by String.toUpperCase() and then performs search. For example, getByCode("jpy", true) returns null, but on the other hand, getByCode("jpy", false) returns CurrencyCode.JPY.
        Returns:
        A CurrencyCode instance, or null if not found.
      • getByCode

        public static CurrencyCode getByCode​(int code)
        Get a CurrencyCode that corresponds to the given ISO 4217 numeric code.
        Parameters:
        code - ISO 4217 numeric code.
        Returns:
        A CurrencyCode instance, or null if not found. If 0 or a negative value is given, null is returned.
      • canonicalize

        private static java.lang.String canonicalize​(java.lang.String code,
                                                     boolean caseSensitive)
      • getByCountry

        public static java.util.List<CurrencyCode> getByCountry​(java.lang.String country)
        Get a list of CurrencyCode instances whose country list contains the specified country.

        This method is an alias of getByCountry(country, true). Note that the behavior has changed since the version 1.13. In the older versions, this method was an alias of getByCountry(code, false).

        Parameters:
        country - Country code. ISO 3166-1 alpha-2 or alpha-3.
        Returns:
        List of CurrencyCode instances. If there is no CurrencyCode instance whose country list contains the specified country, the size of the returned list is zero.
      • getByCountryIgnoreCase

        public static java.util.List<CurrencyCode> getByCountryIgnoreCase​(java.lang.String country)
        Get a list of CurrencyCode instances whose country list contains the specified country.

        This method is an alias of getByCountry(country, false).

        Parameters:
        country - Country code. ISO 3166-1 alpha-2 or alpha-3.
        Returns:
        List of CurrencyCode instances. If there is no CurrencyCode instance whose country list contains the specified country, the size of the returned list is zero.
        Since:
        1.13
      • getByCountry

        public static java.util.List<CurrencyCode> getByCountry​(java.lang.String country,
                                                                boolean caseSensitive)
        Get a list of CurrencyCode instances whose country list contains the specified country.

        This method is an alias of getByCountry(CountryCode.getByCode (country, caseSensitive)).

        Parameters:
        country - Country code. ISO 3166-1 alpha-2 or alpha-3.
        caseSensitive - If true, the given code should consist of uppercase letters only. If false, case is ignored.
        Returns:
        List of CurrencyCode instances. If there is no CurrencyCode instance whose country list contains the specified country, the size of the returned list is zero.
      • getByCountry

        public static java.util.List<CurrencyCode> getByCountry​(CountryCode country)
        Get a list of CurrencyCode instances whose country list contains the specified country.
        Parameters:
        country - CountryCode instance that represents a country.
        Returns:
        List of CurrencyCode instances. If there is no CurrencyCode instance whose country list contains the specified country, the size of the returned list is zero.
      • findByName

        public static java.util.List<CurrencyCode> findByName​(java.lang.String regex)
        Get a list of CurrencyCode by a name regular expression.

        This method is almost equivalent to findByName(Pattern.compile(regex)).

        Parameters:
        regex - Regular expression for names.
        Returns:
        List of CurrencyCode. If nothing has matched, an empty list is returned.
        Throws:
        java.lang.IllegalArgumentException - regex is null.
        java.util.regex.PatternSyntaxException - regex failed to be compiled.
        Since:
        1.11
      • findByName

        public static java.util.List<CurrencyCode> findByName​(java.util.regex.Pattern pattern)
        Get a list of CurrencyCode by a name pattern.

        For example, the list obtained by the code snippet below:

         Pattern pattern = Pattern.compile(".*Ruble");
         List<CurrencyCode> list = CurrencyCode.findByName(pattern);

        contains 4 CurrencyCodes as listed below.

        1. BYN : Belarusian Ruble
        2. BYR : Belarusian Ruble
        3. RUB : Russian Ruble
        4. RUR : Russian Ruble
        Parameters:
        pattern - Pattern to match names.
        Returns:
        List of CurrencyCde. If nothing has matched, an empty list is returned.
        Throws:
        java.lang.IllegalArgumentException - pattern is null.
        Since:
        1.11