author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Wed, 01 Oct 2008 10:43:05 +0200 | |
changeset 29 | f6073056b9fe |
parent 6 | task1/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java@97662396c0fd |
permissions | -rw-r--r-- |
japod@6 | 1 |
package org.apidesign.apifest08.currency; |
japod@6 | 2 |
|
japod@6 | 3 |
/** |
japod@6 | 4 |
* Convertor factory is a factory class for creating {@link Convertor Convertor} |
japod@6 | 5 |
* instances. |
japod@6 | 6 |
* |
japod@6 | 7 |
* @author jindra |
japod@6 | 8 |
*/ |
japod@6 | 9 |
public final class ConvertorFactory { |
japod@6 | 10 |
|
japod@6 | 11 |
// this class needs no instances |
japod@6 | 12 |
private ConvertorFactory() { |
japod@6 | 13 |
} |
japod@6 | 14 |
|
japod@6 | 15 |
|
japod@6 | 16 |
/** |
japod@6 | 17 |
* Create a {@link Convertor Convertor} with given exchange rate |
japod@6 | 18 |
* |
japod@6 | 19 |
* @param exchangeRate double reprezenting the exchange rate from primary currency into |
japod@6 | 20 |
* the secundary currecny |
japod@6 | 21 |
* @return {@link Convertor Convertor} instance with given exchange rate |
japod@6 | 22 |
*/ |
japod@6 | 23 |
public static Convertor createConvertor(double exchangeRate) { |
japod@6 | 24 |
if (exchangeRate == 0) { |
japod@6 | 25 |
throw new IllegalArgumentException("Zero exchange rate is not allowed."); |
japod@6 | 26 |
} |
japod@6 | 27 |
return new ConvertorImpl(exchangeRate); |
japod@6 | 28 |
|
japod@6 | 29 |
} |
japod@6 | 30 |
} |