task4/solution14/src/org/apidesign/apifest08/currency/CurrencyRateFactory.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 17 Oct 2008 17:35:52 +0200
changeset 67 bf7622ec1713
parent 61 58ec6da75f6f
permissions -rw-r--r--
Solution 14, task4
japod@49
     1
package org.apidesign.apifest08.currency;
japod@49
     2
japod@49
     3
japod@49
     4
public final class CurrencyRateFactory {
japod@49
     5
japod@49
     6
    //Singleton
japod@49
     7
    private static CurrencyRateFactory thisFactory = new CurrencyRateFactory();
japod@49
     8
    private CurrencyRateFactory() {};
japod@49
     9
    public static CurrencyRateFactory getInstance() {
japod@49
    10
        return thisFactory;
japod@49
    11
    }
japod@49
    12
japod@49
    13
    public CurrencyRate createCurrencyRate(final String currency1, final String currency2, final Rate rate) {
japod@49
    14
        return new CurrencyRateImpl(currency1, currency2, rate);
japod@49
    15
    }
japod@49
    16
    
japod@49
    17
    public CurrencyRate createCurrencyRate(final String currency1, final String currency2, int amount1, int amount2) {
japod@49
    18
        return new CurrencyRateImpl(currency1, currency2, new Rate(amount1, amount2));
japod@49
    19
    }
japod@49
    20
japod@49
    21
    public CurrencyRate createCurrencyRate(final String currency1, final String currency2, double amount1, double amount2) {
japod@49
    22
        return new CurrencyRateImpl(currency1, currency2, new Rate(amount1, amount2));
japod@49
    23
    }
jaroslav@67
    24
jaroslav@67
    25
    public TimeLimitedCurrencyRate createCurrencyRateTimeLimited(final String currency1, final String currency2, final Rate rate, long fromTime, long toTime) {
jaroslav@67
    26
        return new CurrencyRateImpl(currency1, currency2, rate, fromTime, toTime);
jaroslav@67
    27
    }
jaroslav@67
    28
jaroslav@67
    29
    public TimeLimitedCurrencyRate createCurrencyRateTimeLimited(final String currency1, final String currency2, int amount1, int amount2, long fromTime, long toTime) {
jaroslav@67
    30
        return new CurrencyRateImpl(currency1, currency2, new Rate(amount1, amount2), fromTime, toTime);
jaroslav@67
    31
    }
jaroslav@67
    32
jaroslav@67
    33
    public TimeLimitedCurrencyRate createCurrencyRateTimeLimited(final String currency1, final String currency2, double amount1, double amount2, long fromTime, long toTime) {
jaroslav@67
    34
        return new CurrencyRateImpl(currency1, currency2, new Rate(amount1, amount2), fromTime, toTime);
jaroslav@67
    35
    }
japod@49
    36
    
japod@49
    37
}