Class IsoUtils


  • public final class IsoUtils
    extends java.lang.Object
    Helper API to check country and currency codes using Java Currency and Locale API.

    The list of valid currency and country codes can be manipulated after initialization in order to change or add new values. This can be particularly helpful when the application is not running on the latest Java version and a currency change or addition has not yet been updated in the used JRE.

    Since:
    7.9.2
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCountry​(java.lang.String countryCode)
      Adds the given country code to the current list of codes, verifying that it does not exist previously.
      void addCurrency​(java.lang.String currencyCode)
      Adds the given currency code to the current list of codes, verifying that it does not exist previously.
      java.util.Set<java.lang.String> getCountries()  
      java.util.Set<java.lang.String> getCurrencies()  
      static IsoUtils getInstance()  
      boolean isValidISOCountry​(java.lang.String countryCode)
      Checks if the country code is a valid ISO country using Java Locale.getISOCountries()
      boolean isValidISOCurrency​(java.lang.String currencyCode)
      Checks if the currency code is a valid ISO currency using Java Currency
      void setCountries​(java.util.Set<java.lang.String> countries)  
      void setCurrencies​(java.util.Set<java.lang.String> currencies)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static IsoUtils getInstance()
      • getCurrencies

        public java.util.Set<java.lang.String> getCurrencies()
      • setCurrencies

        public void setCurrencies​(java.util.Set<java.lang.String> currencies)
      • getCountries

        public java.util.Set<java.lang.String> getCountries()
      • setCountries

        public void setCountries​(java.util.Set<java.lang.String> countries)
      • isValidISOCurrency

        public boolean isValidISOCurrency​(java.lang.String currencyCode)
        Checks if the currency code is a valid ISO currency using Java Currency
        Parameters:
        currencyCode - a three letters capitalized currency code, example: USD
        Returns:
        true if currency code is valid, false if it is blank or not valid
      • isValidISOCountry

        public boolean isValidISOCountry​(java.lang.String countryCode)
        Checks if the country code is a valid ISO country using Java Locale.getISOCountries()
        Parameters:
        countryCode - a two letters capitalized country code, example: US
        Returns:
        true if country code is valid, false if it is blank or not valid
      • addCountry

        public void addCountry​(java.lang.String countryCode)
        Adds the given country code to the current list of codes, verifying that it does not exist previously.
        Parameters:
        countryCode - a two capital letters country code, for example: XK
        Throws:
        java.lang.IllegalArgumentException - if the parameter code is null or not two uppercase letters
        Since:
        7.9.7
      • addCurrency

        public void addCurrency​(java.lang.String currencyCode)
        Adds the given currency code to the current list of codes, verifying that it does not exist previously.
        Parameters:
        currencyCode - a three capital letters currency code, for example: ARS
        Throws:
        java.lang.IllegalArgumentException - if the parameter code is null or not three uppercase letters
        Since:
        7.9.7