1 package org.apidesign.apifest08.currency;
3 import java.util.Currency;
7 * Converts one currency to other. The conversion is unidirectional.
8 * For example you can have convertor that converts USD (sourceCurrency) to CZK (destination currency). You can call the {@link Convertor#convert(Money)} method
9 * 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
10 * convertor. To create a convertor instance call {@link ConvertorFactory#createConvertor(Currency, Currency)}.
12 public interface Convertor {
14 * Converts amount in source currency to amount in destination currency. The result is rounded to two decimal places.
17 * @throws IllegalArgumentException if money.getCurrency is not equal to sourceCurrency.
19 public Money convert(Money money);
22 * Returns convertor that converts from destination currency to source currency with the same exchange rate.
25 public Convertor revert();
28 * Returns source currency.
31 public Currency getSourceCurrency();
34 * Returns destination currency.
37 public Currency getDestinationCurrency();