1 package org.apidesign.apifest08.currency;
4 * Convertor factory is a factory class for creating {@link Convertor Convertor}
9 public final class ConvertorFactory {
11 // this class needs no instances
12 private ConvertorFactory() {
17 * Create a {@link Convertor Convertor} with given exchange rate
19 * @param exchangeRate double reprezenting the exchange rate from primary currency into
20 * the secundary currecny
21 * @return {@link Convertor Convertor} instance with given exchange rate
23 public static Convertor createConvertor(double exchangeRate) {
24 if (exchangeRate == 0) {
25 throw new IllegalArgumentException("Zero exchange rate is not allowed.");
27 return new ConvertorImpl(exchangeRate);