1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/ConvertorFactory.java Wed Oct 01 10:43:05 2008 +0200
1.3 @@ -0,0 +1,31 @@
1.4 +package org.apidesign.apifest08.currency;
1.5 +
1.6 +
1.7 +
1.8 +/**
1.9 + * Creates {@link Convertor} implementations.
1.10 + * @author lukas
1.11 + *
1.12 + */
1.13 +public class ConvertorFactory {
1.14 + private ConvertorFactory()
1.15 + {
1.16 + //nothing
1.17 + }
1.18 +
1.19 + /**
1.20 + * Creates {@link Convertor} that converts from sourceEquivalent.currency to destinationEquivalent.currency.
1.21 + * Exchange rate is set as equivalents. It means if you want to create USD to CZK convertor where USD1 = CZK17
1.22 + * call createConvertor(new MoneyImpl(1, USD), new MoneyImpl(17, CZK)). Convertor created by this method
1.23 + * rounds the result to two decimal places.
1.24 + * @param sourceEquivalent
1.25 + * @param destinationEquivalent
1.26 + * @return
1.27 + */
1.28 + public static final Convertor createConvertor(Money sourceEquivalent, Money destinationEquivalent)
1.29 + {
1.30 + return new DefaultConvertor(sourceEquivalent.getAmount(), destinationEquivalent.getAmount(), sourceEquivalent.getCurrency(), destinationEquivalent.getCurrency());
1.31 + }
1.32 +
1.33 +
1.34 +}