1 package org.apidesign.apifest08.currency;
3 import java.math.BigDecimal;
4 import java.util.Currency;
8 final class DatedConvertorImpl
10 implements DatedConvertor
12 private final DateRange range;
14 DatedConvertorImpl(final DateRange rng,
21 throw new IllegalArgumentException("rng cannot be null");
27 public DateRange getDateRange()
33 public BigDecimal convert(final Currency from,
35 final BigDecimal amount)
36 throws InvalidConversionException
38 final BigDecimal total;
40 total = convert(from, to, amount, new Date(System.currentTimeMillis()));
45 public BigDecimal convert(final Currency from,
47 final BigDecimal amount,
49 throws InvalidConversionException
51 final BigDecimal total;
53 if(range.isInRange(date))
55 total = super.convert(from, to, amount);
59 throw new InvalidConversionException("cannot convert for date", from);
65 public boolean canConvert(final Currency from,
71 if(canConvert(from, to))
73 retVal = range.isInRange(date);