1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/task2/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java Wed Oct 01 10:43:05 2008 +0200
1.3 @@ -0,0 +1,30 @@
1.4 +package org.apidesign.apifest08.currency;
1.5 +
1.6 +/**
1.7 + * Convertor factory is a factory class for creating {@link Convertor Convertor}
1.8 + * instances.
1.9 + *
1.10 + * @author jindra
1.11 + */
1.12 +public final class ConvertorFactory {
1.13 +
1.14 + // this class needs no instances
1.15 + private ConvertorFactory() {
1.16 + }
1.17 +
1.18 +
1.19 + /**
1.20 + * Create a {@link Convertor Convertor} with given exchange rate
1.21 + *
1.22 + * @param exchangeRate double reprezenting the exchange rate from primary currency into
1.23 + * the secundary currecny
1.24 + * @return {@link Convertor Convertor} instance with given exchange rate
1.25 + */
1.26 + public static Convertor createConvertor(double exchangeRate) {
1.27 + if (exchangeRate == 0) {
1.28 + throw new IllegalArgumentException("Zero exchange rate is not allowed.");
1.29 + }
1.30 + return new ConvertorImpl(exchangeRate);
1.31 +
1.32 + }
1.33 +}