task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java
1 package org.apidesign.apifest08.currency;
6 * CurrencyConversionService provides methods necessary for construction all necessary currency
7 * conversion-related classes.
9 public interface CurrencyConverterProvider {
12 * Convenience method for getConverter(amount1, Currency.getInstance(currency1));
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
22 CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
23 double amount2, /*@NotNull*/ String currency2)
24 throws IllegalArgumentException, CurrencyNotAvailableException;
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].
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
41 CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
42 double amount2, /*@NotNull*/ Currency currency2)
43 throws IllegalArgumentException, CurrencyNotAvailableException;
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.
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
54 CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies)
55 throws CurrencyNotAvailableException, NullPointerException;
58 * Convenient method for getConverter(Currency...)
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
66 CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
67 throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException;