task2/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java
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--
Getting ready for task2: copying all solutions to new locations
     1 package org.apidesign.apifest08.currency;
     2 
     3 /**
     4  * Convertor factory is a factory class for creating {@link Convertor Convertor}
     5  * instances.
     6  *
     7  * @author jindra
     8  */
     9 public final class ConvertorFactory {
    10 
    11     // this class needs no instances
    12     private ConvertorFactory() {
    13     }
    14 
    15 
    16     /**
    17      * Create a {@link Convertor Convertor} with given exchange rate
    18      *
    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
    22      */
    23     public static Convertor createConvertor(double exchangeRate) {
    24         if (exchangeRate == 0) {
    25             throw new IllegalArgumentException("Zero exchange rate is not allowed.");
    26         }
    27         return new ConvertorImpl(exchangeRate);
    28 
    29     }
    30 }