1 package org.apidesign.apifest08.currency;
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.
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
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.
15 public interface CurrencyConverter {
18 * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
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
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;
35 * Converts the specified value from one currency (from) to target currency (to).
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
46 double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
47 throws CurrencyConversionException, NullPointerException;