1.1 --- a/task2/solution02/src/org/apidesign/apifest08/currency/ConvertorFactory.java Wed Oct 01 10:43:05 2008 +0200
1.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/ConvertorFactory.java Tue Oct 07 00:19:37 2008 +0200
1.3 @@ -22,9 +22,24 @@
1.4 * @param destinationEquivalent
1.5 * @return
1.6 */
1.7 - public static final Convertor createConvertor(Money sourceEquivalent, Money destinationEquivalent)
1.8 + public static final ExtendedConvertor createConvertor(Money sourceEquivalent, Money destinationEquivalent)
1.9 {
1.10 - return new DefaultConvertor(sourceEquivalent.getAmount(), destinationEquivalent.getAmount(), sourceEquivalent.getCurrency(), destinationEquivalent.getCurrency());
1.11 + return mergeConvertors(
1.12 + new DefaultConvertor(sourceEquivalent, destinationEquivalent),
1.13 + new DefaultConvertor(destinationEquivalent ,sourceEquivalent)
1.14 + );
1.15 + }
1.16 +
1.17 + /**
1.18 + * Merges convertors. The resulting convertor has ability to do all conversions that its underlying
1.19 + * convertors could do. No consistency validation is done, inconsistent input will result in a convertor with
1.20 + * inconsistent behavior.
1.21 + * @param convertors
1.22 + * @return
1.23 + */
1.24 + public static final ExtendedConvertor mergeConvertors(ExtendedConvertor... convertors)
1.25 + {
1.26 + return new CompositeConvertor(convertors);
1.27 }
1.28
1.29