/** * Return a {@link CurrencyUnit} instances matching the given * {@link javax.money.CurrencyQuery}. * * @param query the {@link javax.money.CurrencyQuery} containing the parameters determining the query. not null. * @return the corresponding {@link CurrencyUnit}s matching, never null. */ @Override public Set<CurrencyUnit> getCurrencies(CurrencyQuery query){ // Query for currencyCode BTC or default query returns bitcoinSet else emptySet. return (query.getCurrencyCodes().contains("BTC") || query.getCurrencyCodes().isEmpty()) ? bitcoinSet : Collections.emptySet(); } }
/** * Returns the target locales. * * @return the target locales, never null. */ public Collection<Locale> getCountries() { Collection<Locale> result = get(KEY_QUERY_COUNTRIES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
/** * Creates a new instance of {@link javax.money.CurrencyQuery}. * * @return a new {@link javax.money.CurrencyQuery} instance, never null. */ public CurrencyQuery build() { return new CurrencyQuery(this); }
if (currencyQuery.get(LocalDateTime.class) != null || currencyQuery.get(LocalDate.class) != null) { return Collections.emptySet(); if (!currencyQuery.getCurrencyCodes().isEmpty()) { for (String code : currencyQuery.getCurrencyCodes()) { CurrencyUnit cu = CURRENCY_UNITS.get(code); if (cu != null) { if (!currencyQuery.getCountries().isEmpty()) { for (Locale locale : currencyQuery.getCountries()) { CurrencyUnit cu = CURRENCY_UNITS_BY_LOCALE.get(locale); if (cu != null) {
if(!currencyQuery.getCurrencyCodes().isEmpty()) { for (String code : currencyQuery.getCurrencyCodes()) { CurrencyUnit cu = CACHED.get(code); if (cu != null) { if(!currencyQuery.getCountries().isEmpty()) { for (Locale country : currencyQuery.getCountries()) { CurrencyUnit cu = getCurrencyUnit(country); if (cu != null) { if(!currencyQuery.getNumericCodes().isEmpty()) { for (Integer numCode : currencyQuery.getNumericCodes()) { List<CurrencyUnit> cus = getCurrencyUnits(numCode); result.addAll(cus);
@Override public Set<CurrencyUnit> getCurrencies(CurrencyQuery currencyQuery) { Set<CurrencyUnit> result = new HashSet<>(1); for (String cur : currencyQuery.getCurrencyCodes()) { if (cur.endsWith("_test")) { result.add(new TestCurrencyUnit(cur)); } } for (Locale country : currencyQuery.getCountries()) { if ("test".equals(country.getVariant())) { result.add(new TestCurrencyUnit(country.toString())); } } return result; } }
@Override public Set<CurrencyUnit> getCurrencies(CurrencyQuery query) { if(Boolean.TRUE.equals(query.getBoolean("GeeCon"))) { return currencies; } return Collections.emptySet(); }
private List<CurrencyProviderSpi> collectProviders(CurrencyQuery query) { List<CurrencyProviderSpi> result = new ArrayList<>(); if (!query.getProviderNames().isEmpty()) { for (String providerName : query.getProviderNames()) { CurrencyProviderSpi provider = getProvider(providerName); if (provider == null) { Logger.getLogger(DefaultMonetaryCurrenciesSingletonSpi.class.getName()).warning("No such currency " + "provider found, ignoring: " + providerName); } else { result.add(provider); } } } else{ for(String providerName:getDefaultProviderChain()){ CurrencyProviderSpi provider = getProvider(providerName); if (provider == null) { Logger.getLogger(DefaultMonetaryCurrenciesSingletonSpi.class.getName()).warning("No such currency " + "provider found, ignoring: " + providerName); } else { result.add(provider); } } } return result; }
/** * Gets the currency codes, or the regular expression to select codes. * * @return the query for chaining. */ public Collection<String> getCurrencyCodes() { Collection<String> result = get(KEY_QUERY_CURRENCY_CODES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
/** * Gets the numeric codes. Setting it to -1 search for currencies that have no numeric code. * * @return the query for chaining. */ public Collection<Integer> getNumericCodes() { Collection<Integer> result = get(KEY_QUERY_NUMERIC_CODES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }