1 package org.apidesign.apifest08.currency;
3 import java.math.BigDecimal;
4 import java.util.Currency;
6 public abstract class Convertor {
9 * Converts an amount to another amount according to a given currency.
11 * @param from a source
12 * @param toCurrency a target currency
13 * @return a converted amount
14 * @throws ConversionException if the conversion fails
15 * @throws UnsupportedConversionException if the conversion between a given currencies is not supported.
17 public abstract Amount convert(Amount from, Currency toCurrency) throws ConversionException, UnsupportedConversionException;
20 * Converts an amount value between two currencies.
22 * @param amount an amount
23 * @param fromCurrency an amount currency
24 * @param toCurrency to a target currency
25 * @return a converted amount value
27 * @throws ConversionException if the conversion fails
28 * @throws UnsupportedConversionException if the conversion between a given currencies is not supported.
30 public abstract Amount convert(BigDecimal amount, Currency fromCurrency, Currency toCurrency) throws ConversionException, UnsupportedConversionException;