All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.money.CurrencyQueryBuilder Maven / Gradle / Ivy

Go to download

JSR 354 provides an API for representing, transporting, and performing comprehensive calculations with Money and Currency. This module provides a forward compatible backport of the API.

There is a newer version: 1.0.4
Show newest version
/*
 * CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU
 * ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT. PLEASE READ THE TERMS AND CONDITIONS OF THIS
 * AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF
 * THE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE" BUTTON AT THE
 * BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency API ("Specification") Copyright
 * (c) 2012-2013, Credit Suisse All rights reserved.
 */
package javax.money;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Objects;


/**
 * Builder for queries for accessing {@link CurrencyUnit} instances. If not properties are set the
 * query should
 * returns
 * the default currencies. Similarly if no provider is set explicitly the default ISO currencies as
 * returned by {@link java.util.Currency} should be returned.
 * 

* Note this class is NOT thread-safe. */ public final class CurrencyQueryBuilder extends AbstractQueryBuilder { /** * Default constructor. */ private CurrencyQueryBuilder() { } /** * Creates a new instance of {@link CurrencyQueryBuilder}. * * @param currencyQuery {@link CurrencyQuery} used for initializing this builder. */ private CurrencyQueryBuilder(CurrencyQuery currencyQuery) { Objects.requireNonNull(currencyQuery); importContext(currencyQuery); } /** * Sets the country for which currencies whould be requested. * * @param countries The ISO countries. * @return the query for chaining. */ public CurrencyQueryBuilder setCountries(Locale... countries) { return set(CurrencyQuery.KEY_QUERY_COUNTRIES, Arrays.asList(countries)); } /** * Sets the currency code, or the regular expression to select codes. * * @param codes sthe currency codes or code expressions, not null. * @return the query for chaining. */ public CurrencyQueryBuilder setCurrencyCodes(String... codes) { return set(CurrencyQuery.KEY_QUERY_CURRENCY_CODES, Arrays.asList(codes)); } /** * Set the numeric code. Setting it to -1 search for currencies that have no numeric code. * * @param codes the numeric codes. * @return the query for chaining. */ public CurrencyQueryBuilder setNumericCodes(int... codes) { List intList = new ArrayList(codes.length); for(Integer code:codes){ intList.add(code); } return set(CurrencyQuery.KEY_QUERY_NUMERIC_CODES, intList); } /** * Creates a new instance of {@link CurrencyQuery}. * * @return a new {@link CurrencyQuery} instance, never null. */ public CurrencyQuery build() { return new CurrencyQuery(this); } /** * Creates a new instance of {@link CurrencyQueryBuilder}. * * @return a new {@link CurrencyQueryBuilder} instance, never null. */ public static CurrencyQueryBuilder of() { return new CurrencyQueryBuilder(); } /** * Creates a new instance of {@link CurrencyQueryBuilder}. * * @param currencyQuery {@link CurrencyQuery} used for initializing this builder. * @return a new {@link CurrencyQueryBuilder} instance, never null. */ public static CurrencyQueryBuilder of(CurrencyQuery currencyQuery) { return new CurrencyQueryBuilder(currencyQuery); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy