task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java
changeset 29 f6073056b9fe
parent 6 97662396c0fd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java	Wed Oct 01 10:43:05 2008 +0200
     1.3 @@ -0,0 +1,68 @@
     1.4 +package org.apidesign.apifest08.currency;
     1.5 +
     1.6 +import java.util.*;
     1.7 +
     1.8 +/**
     1.9 + * CurrencyConversionService provides methods necessary for construction all necessary currency
    1.10 + * conversion-related classes.
    1.11 + */
    1.12 +public interface CurrencyConverterProvider {
    1.13 +
    1.14 +	/**
    1.15 +	 * Convenience method for getConverter(amount1, Currency.getInstance(currency1));
    1.16 +	 *
    1.17 +	 * @param amount1 amount of the money in the currency1
    1.18 +	 * @param currency1 one of the supported currencies
    1.19 +	 * @param amount2 amount of the money in the currency2
    1.20 +	 * @param currency2 one of the supported currencies
    1.21 +	 * @return converter able to convert between the two specified currencies
    1.22 +	 * @throws IllegalArgumentException if any of the amount values is not positive
    1.23 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    1.24 +	 */
    1.25 +	CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
    1.26 +								   double amount2, /*@NotNull*/ String currency2)
    1.27 +			throws IllegalArgumentException, CurrencyNotAvailableException;
    1.28 +
    1.29 +	/**
    1.30 +	 * Retrieves converter that is capable of converting values between currency1 and currency2.
    1.31 +	 * The exchange is specified in easy to understand way. By specifying values in two currencies that
    1.32 +	 * are equal. For example CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR.
    1.33 +	 * This enables user to use this method without having to calculate anything. In general this can be
    1.34 +	 * expressed by formula amount1[currency1] = amount2[currency2].
    1.35 +	 *
    1.36 +	 * @param amount1 amount of the money in the currency1
    1.37 +	 * @param currency1 one of the supported currencies
    1.38 +	 * @param amount2 amount of the money in the currency2
    1.39 +	 * @param currency2 one of the supported currencies
    1.40 +	 * @return converter able to convert between the two specified currencies
    1.41 +	 * @throws IllegalArgumentException if any of the amount values is not positive
    1.42 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    1.43 +	 */
    1.44 +	CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
    1.45 +								   double amount2, /*@NotNull*/ Currency currency2)
    1.46 +			throws IllegalArgumentException, CurrencyNotAvailableException;
    1.47 +
    1.48 +	/**
    1.49 +	 * Creates a new converter that is able to convert between all specified currencies. The converter
    1.50 +	 * may optionally support additional currencies that were not specified.
    1.51 +	 *
    1.52 +	 * @param currencies that the converter should be created for
    1.53 +	 * @return converter able to convert between all specified currencies
    1.54 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    1.55 +	 * @throws NullPointerException if any of the specified currencies is null of the array is null
    1.56 +	 */
    1.57 +	CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies)
    1.58 +			throws CurrencyNotAvailableException, NullPointerException;
    1.59 +
    1.60 +	/**
    1.61 +	 * Convenient method for getConverter(Currency...)
    1.62 +	 *
    1.63 +	 * @param currencies that the converter should be created for
    1.64 +	 * @return converter able to convert between all specified currencies
    1.65 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    1.66 +	 * @throws NullPointerException if any of the specified currencies is null, or the array is null
    1.67 +	 * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
    1.68 +	 */
    1.69 +	CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
    1.70 +			throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException;
    1.71 +}
    1.72 \ No newline at end of file