task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.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/CurrencyConverterProvider.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 /**
     6  * CurrencyConversionService provides methods necessary for construction all necessary currency
     7  * conversion-related classes.
     8  */
     9 public interface CurrencyConverterProvider {
    10 
    11 	/**
    12 	 * Convenience method for getConverter(amount1, Currency.getInstance(currency1));
    13 	 *
    14 	 * @param amount1 amount of the money in the currency1
    15 	 * @param currency1 one of the supported currencies
    16 	 * @param amount2 amount of the money in the currency2
    17 	 * @param currency2 one of the supported currencies
    18 	 * @return converter able to convert between the two specified currencies
    19 	 * @throws IllegalArgumentException if any of the amount values is not positive
    20 	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    21 	 */
    22 	CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
    23 								   double amount2, /*@NotNull*/ String currency2)
    24 			throws IllegalArgumentException, CurrencyNotAvailableException;
    25 
    26 	/**
    27 	 * Retrieves converter that is capable of converting values between currency1 and currency2.
    28 	 * The exchange is specified in easy to understand way. By specifying values in two currencies that
    29 	 * are equal. For example CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR.
    30 	 * This enables user to use this method without having to calculate anything. In general this can be
    31 	 * expressed by formula amount1[currency1] = amount2[currency2].
    32 	 *
    33 	 * @param amount1 amount of the money in the currency1
    34 	 * @param currency1 one of the supported currencies
    35 	 * @param amount2 amount of the money in the currency2
    36 	 * @param currency2 one of the supported currencies
    37 	 * @return converter able to convert between the two specified currencies
    38 	 * @throws IllegalArgumentException if any of the amount values is not positive
    39 	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    40 	 */
    41 	CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
    42 								   double amount2, /*@NotNull*/ Currency currency2)
    43 			throws IllegalArgumentException, CurrencyNotAvailableException;
    44 
    45 	/**
    46 	 * Creates a new converter that is able to convert between all specified currencies. The converter
    47 	 * may optionally support additional currencies that were not specified.
    48 	 *
    49 	 * @param currencies that the converter should be created for
    50 	 * @return converter able to convert between all specified currencies
    51 	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    52 	 * @throws NullPointerException if any of the specified currencies is null of the array is null
    53 	 */
    54 	CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies)
    55 			throws CurrencyNotAvailableException, NullPointerException;
    56 
    57 	/**
    58 	 * Convenient method for getConverter(Currency...)
    59 	 *
    60 	 * @param currencies that the converter should be created for
    61 	 * @return converter able to convert between all specified currencies
    62 	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
    63 	 * @throws NullPointerException if any of the specified currencies is null, or the array is null
    64 	 * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
    65 	 */
    66 	CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
    67 			throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException;
    68 }