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