task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.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/CurrencyConverter.java	Wed Oct 01 10:43:05 2008 +0200
     1.3 @@ -0,0 +1,48 @@
     1.4 +package org.apidesign.apifest08.currency;
     1.5 +
     1.6 +import java.util.*;
     1.7 +
     1.8 +/** This is the skeleton class for your API. You need to make it public, so
     1.9 + * it is accessible to your client code (currently in Task1Test.java) file.
    1.10 + * <p>
    1.11 + * Feel free to create additional classes or rename this one, just keep all
    1.12 + * the API and its implementation in this package. Do not spread it outside
    1.13 + * to other packages.
    1.14 + *
    1.15 + * The converter will usually work internally with Currency class, to be more type-safe as String can be used
    1.16 + * for almost anything. But methods taking strings as parameters are provided for convenience.
    1.17 + */
    1.18 +public interface CurrencyConverter {
    1.19 +
    1.20 +	/**
    1.21 +	 * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
    1.22 +	 *
    1.23 +	 * @param value that should be converted form one currency to the other
    1.24 +	 * @param from ISO-4217 code of the currency of the value provided
    1.25 +	 * @param to ISO-4212 code of the currency to which the value should be converted
    1.26 +	 * @return value expressed in the target value
    1.27 +	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
    1.28 +	 * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
    1.29 +	 * for example the exchange rates are not current, connection to exchange rates provider is not available
    1.30 +	 * @throws NullPointerException if any of the specified currency ISO codes is null
    1.31 +	 */
    1.32 +	// this method is provided to ensure future compatibility for converters supporting more than 2 currencies
    1.33 +	//		- simpler methods with fewer arguments would make using such converters less intuitive
    1.34 +	double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
    1.35 +			throws CurrencyConversionException, NullPointerException, IllegalArgumentException;
    1.36 +
    1.37 +	/**
    1.38 +	 * Converts the specified value from one currency (from) to target currency (to).
    1.39 +	 *
    1.40 +	 * @param value that should be converted form one currency to the other
    1.41 +	 * @param from ISO-4217 code of the currency of the value provided
    1.42 +	 * @param to ISO-4212 code of the currency to which the value should be converted
    1.43 +	 * @return value expressed in the target value
    1.44 +	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
    1.45 +	 * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
    1.46 +	 * for example the exchange rates are not current, connection to exchange rates provider is not available
    1.47 +	 * @throws NullPointerException if any of the specified currency ISO codes is null
    1.48 +	 */
    1.49 +	double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
    1.50 +			throws CurrencyConversionException, NullPointerException;
    1.51 +}