2 package org.apidesign.apifest08.currency;
4 import java.math.BigDecimal;
8 * Exchange rate provider - can provide fixed exchange rate which does not depend
9 * on date (method {@link #getExchangeRate()} ) or exchange rate based on date (method {@link #getExchangeRate(java.util.Date) }).
12 * @author arnostvalicek
14 public class ExchangeRateProvider {
15 BigDecimal fromValue, toValue;
16 ConvertorCurrency fromCurrency, toCurrency;
19 * Simple constructor for <code>ExchangeRateProviderM</code> which can provide fixed exchange rate.
21 * Describes conversion <em>from</em> to <em>to</em> currency.
23 * @param fromValue From value. BigDecimal value, precision should be set to currency precision.
24 * @param fromCurrency From currency.
25 * @param toValue To value. BigDecimal value, precision should be set to currency precision.
26 * @param toCurrency To currency.
28 public ExchangeRateProvider(BigDecimal fromValue, ConvertorCurrency fromCurrency, BigDecimal toValue, ConvertorCurrency toCurrency) {
29 this.fromValue = fromValue;
30 this.toValue = toValue;
31 this.fromCurrency = fromCurrency;
32 this.toCurrency = toCurrency;
36 * Get fixed exange rate for currencies (from->to).
37 * @return Returns exchange rate.
39 public ExchangeRate getExchangeRate() {
40 return new ExchangeRate(fromValue, toValue);
44 * Get exchange rate for currencies (from->to) based on provided date.
45 * @param date Date for which exchange rate should be provided.
46 * @return Returns exchange rate
48 public ExchangeRate getExchangeRate(Date date) {
49 return new ExchangeRate(fromValue, toValue);
53 ConvertorCurrency getFromCurrency() {
57 ConvertorCurrency getToCurrency() {