1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/task1/solution02/src/org/apidesign/apifest08/currency/Convertor.java Sun Sep 28 14:12:38 2008 +0200
1.3 @@ -0,0 +1,38 @@
1.4 +package org.apidesign.apifest08.currency;
1.5 +
1.6 +import java.util.Currency;
1.7 +
1.8 +
1.9 +/**
1.10 + * Converts one currency to other. The conversion is unidirectional.
1.11 + * For example you can have convertor that converts USD (sourceCurrency) to CZK (destination currency). You can call the {@link Convertor#convert(Money)} method
1.12 + * with amount in USD to get the equivalent in CZK. If you need convert CZK to USD you can call {@link Convertor#revert()} method to get CZK to USD
1.13 + * convertor. To create a convertor instance call {@link ConvertorFactory#createConvertor(Currency, Currency)}.
1.14 + */
1.15 +public interface Convertor {
1.16 + /**
1.17 + * Converts amount in source currency to amount in destination currency. The result is rounded to two decimal places.
1.18 + * @param money
1.19 + * @return
1.20 + * @throws IllegalArgumentException if money.getCurrency is not equal to sourceCurrency.
1.21 + */
1.22 + public Money convert(Money money);
1.23 +
1.24 + /**
1.25 + * Returns convertor that converts from destination currency to source currency with the same exchange rate.
1.26 + * @return
1.27 + */
1.28 + public Convertor revert();
1.29 +
1.30 + /**
1.31 + * Returns source currency.
1.32 + * @return
1.33 + */
1.34 + public Currency getSourceCurrency();
1.35 +
1.36 + /**
1.37 + * Returns destination currency.
1.38 + * @return
1.39 + */
1.40 + public Currency getDestinationCurrency();
1.41 +}