task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 01 Oct 2008 10:43:05 +0200
changeset 29 f6073056b9fe
parent 6 task1/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.java@97662396c0fd
permissions -rw-r--r--
Getting ready for task2: copying all solutions to new locations
     1 package org.apidesign.apifest08.currency;
     2 
     3 import java.util.*;
     4 
     5 /** This is the skeleton class for your API. You need to make it public, so
     6  * it is accessible to your client code (currently in Task1Test.java) file.
     7  * <p>
     8  * Feel free to create additional classes or rename this one, just keep all
     9  * the API and its implementation in this package. Do not spread it outside
    10  * to other packages.
    11  *
    12  * The converter will usually work internally with Currency class, to be more type-safe as String can be used
    13  * for almost anything. But methods taking strings as parameters are provided for convenience.
    14  */
    15 public interface CurrencyConverter {
    16 
    17 	/**
    18 	 * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
    19 	 *
    20 	 * @param value that should be converted form one currency to the other
    21 	 * @param from ISO-4217 code of the currency of the value provided
    22 	 * @param to ISO-4212 code of the currency to which the value should be converted
    23 	 * @return value expressed in the target value
    24 	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
    25 	 * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
    26 	 * for example the exchange rates are not current, connection to exchange rates provider is not available
    27 	 * @throws NullPointerException if any of the specified currency ISO codes is null
    28 	 */
    29 	// this method is provided to ensure future compatibility for converters supporting more than 2 currencies
    30 	//		- simpler methods with fewer arguments would make using such converters less intuitive
    31 	double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
    32 			throws CurrencyConversionException, NullPointerException, IllegalArgumentException;
    33 
    34 	/**
    35 	 * Converts the specified value from one currency (from) to target currency (to).
    36 	 *
    37 	 * @param value that should be converted form one currency to the other
    38 	 * @param from ISO-4217 code of the currency of the value provided
    39 	 * @param to ISO-4212 code of the currency to which the value should be converted
    40 	 * @return value expressed in the target value
    41 	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
    42 	 * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
    43 	 * for example the exchange rates are not current, connection to exchange rates provider is not available
    44 	 * @throws NullPointerException if any of the specified currency ISO codes is null
    45 	 */
    46 	double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
    47 			throws CurrencyConversionException, NullPointerException;
    48 }