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