Class LocaleService

java.lang.Object
com.bluebell.greenhouse.radicle.services.locale.LocaleService

@Service public class LocaleService extends Object
Service-layer for country and currency lookups.
Version:
3.0.6
Author:
Stephen Prizio
  • Constructor Details

    • LocaleService

      public LocaleService()
  • Method Details

    • getCountryPhoneCodes

      @Cacheable(cacheNames="localeReference", key="'countryPhoneCodes'") public SortedSet<String> getCountryPhoneCodes()
      Returns the supported country phone codes.
      Returns:
      TreeSet of phone codes
    • getCountryIsoCodes

      @Cacheable(cacheNames="localeReference", key="'countryIsoCodes'") public SortedSet<String> getCountryIsoCodes()
      Returns the supported country ISO codes.
      Returns:
      TreeSet of ISO codes
    • getCurrencyIsoCodes

      @Cacheable(cacheNames="localeReference", key="'currencyIsoCodes'") public SortedSet<String> getCurrencyIsoCodes()
      Returns the supported currency ISO codes.
      Returns:
      TreeSet of ISO codes
    • getCountries

      @Cacheable(cacheNames="localeReference", key="'countries'") public List<CountryDTO> getCountries()
      Returns all supported countries.
      Returns:
      List of CountryDTO
    • getCurrencies

      @Cacheable(cacheNames="localeReference", key="'currencies'") public List<CurrencyDTO> getCurrencies()
      Returns all supported currencies.
      Returns:
      List of CurrencyDTO
    • getCountryForCurrency

      public Country getCountryForCurrency(String currencyIsoCode)
      Returns the default country for the given currency ISO code.
      Parameters:
      currencyIsoCode - ISO 4217 currency code
      Returns:
      Country
    • getCurrencyForCountry

      public Currency getCurrencyForCountry(String countryIsoCode)
      Returns the default currency for the given country ISO code.
      Parameters:
      countryIsoCode - ISO 3166-1 alpha-3 country code
      Returns:
      Currency
    • getCountry

      public Country getCountry(String countryIsoCode)
      Returns the country for the given ISO code.
      Parameters:
      countryIsoCode - ISO 3166-1 alpha-3 country code
      Returns:
      Country
    • getCurrency

      public Currency getCurrency(String currencyIsoCode)
      Returns the currency for the given ISO code.
      Parameters:
      currencyIsoCode - ISO 4217 currency code
      Returns:
      Currency
    • isSupportedLocale

      public boolean isSupportedLocale(String locale)
      Checks if the given string is a supported locale token.
      Parameters:
      locale - locale token
      Returns:
      true if supported
    • matchesLocale

      public boolean matchesLocale(Country country, String locale)
      Checks whether the given country matches the locale token.
      Parameters:
      country - country
      locale - locale token
      Returns:
      true if matched
    • findCountry

      public Optional<Country> findCountry(String countryIsoCode)
      Attempts to resolve a country by ISO code.
      Parameters:
      countryIsoCode - ISO 3166-1 alpha-3 country code
      Returns:
      Optional Country
    • findCountryByIsoCodeOrCode

      public Optional<Country> findCountryByIsoCodeOrCode(String countryValue)
      Attempts to resolve a country by ISO code first, then by the legacy enum code.
      Parameters:
      countryValue - ISO 3166-1 alpha-3 country code or legacy enum code
      Returns:
      Optional Country
    • findCurrency

      public Optional<Currency> findCurrency(String currencyIsoCode)
      Attempts to resolve a currency by ISO code.
      Parameters:
      currencyIsoCode - ISO 4217 currency code
      Returns:
      Optional Currency
    • findCurrencyByIsoCodeOrCode

      public Optional<Currency> findCurrencyByIsoCodeOrCode(String currencyValue)
      Attempts to resolve a currency by ISO code first, then by the legacy enum code.
      Parameters:
      currencyValue - ISO 4217 currency code or legacy enum code
      Returns:
      Optional Currency
    • findCountryForCurrency

      public Optional<Country> findCountryForCurrency(String currencyIsoCode)
      Attempts to resolve the default country for a currency ISO code.
      Parameters:
      currencyIsoCode - ISO 4217 currency code
      Returns:
      Optional Country