author | japod@localhost |
Sun, 28 Sep 2008 14:12:38 +0200 | |
changeset 6 | 97662396c0fd |
permissions | -rw-r--r-- |
japod@6 | 1 |
package org.apidesign.apifest08.currency; |
japod@6 | 2 |
|
japod@6 | 3 |
import java.util.Currency; |
japod@6 | 4 |
|
japod@6 | 5 |
/** |
japod@6 | 6 |
* Convertor Factory implementation |
japod@6 | 7 |
* In the real-time world this code should be optimized - convertors caching etc. |
japod@6 | 8 |
* @author Ladislav Vitasek |
japod@6 | 9 |
*/ |
japod@6 | 10 |
class CurrencyConvertorFactoryImpl extends AbstractConvertorFactory { |
japod@6 | 11 |
|
japod@6 | 12 |
|
japod@6 | 13 |
CurrencyConvertorFactoryImpl() { |
japod@6 | 14 |
super(); |
japod@6 | 15 |
} |
japod@6 | 16 |
|
japod@6 | 17 |
// Note - implementation of this method is dummy |
japod@6 | 18 |
|
japod@6 | 19 |
public Convertor createConvertor(Currency currency1, Currency currency2, ConversionProperties conversionProperties) throws ConvertorNotAvailableException { |
japod@6 | 20 |
if (currency1 == null || currency2 == null || conversionProperties == null) |
japod@6 | 21 |
throw new NullPointerException(); |
japod@6 | 22 |
|
japod@6 | 23 |
try { |
japod@6 | 24 |
return new CurrencyConvertorImpl(currency1, currency2, conversionProperties.getConversionRatioProvider(), conversionProperties.getRoundingMode());//can be cached somehow |
japod@6 | 25 |
} catch (Exception e) { |
japod@6 | 26 |
throw new ConvertorNotAvailableException(e); |
japod@6 | 27 |
} |
japod@6 | 28 |
} |
japod@6 | 29 |
} |