task4/solution14/src/org/apidesign/apifest08/currency/CurrencyRateImpl.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 11 Oct 2008 23:38:46 +0200
changeset 61 58ec6da75f6f
parent 50 task3/solution14/src/org/apidesign/apifest08/currency/CurrencyRateImpl.java@03c5c5dc94e7
child 67 bf7622ec1713
permissions -rw-r--r--
Copying structure for task4
japod@49
     1
japod@49
     2
package org.apidesign.apifest08.currency;
japod@49
     3
japod@49
     4
public final class CurrencyRateImpl implements CurrencyRate {
japod@49
     5
    private String currency1;
japod@49
     6
    private String currency2;
japod@49
     7
    private Rate rate;
japod@49
     8
    
japod@49
     9
    CurrencyRateImpl(final String currency1, final String currency2, final Rate rate) {
japod@49
    10
        if ((currency1 == null)||(currency2 == null) || (rate == null)) {
japod@49
    11
            throw new IllegalArgumentException("Argument cannot be null.");
japod@49
    12
        }
japod@49
    13
        if ("".equals(currency1) || "".equals(currency2)) {
japod@49
    14
            throw new IllegalArgumentException("Name of currency cannot be empty string");
japod@49
    15
        }
japod@49
    16
        if (currency1.equals(currency2)) {
japod@49
    17
            throw new IllegalArgumentException("Currencies in rate cannot be the same");
japod@49
    18
        }
japod@49
    19
       
japod@49
    20
        this.currency1 = currency1;
japod@49
    21
        this.currency2 = currency2;
japod@49
    22
        this.rate = rate;
japod@49
    23
    }
japod@49
    24
japod@49
    25
    public String getCurrency1() {
japod@49
    26
        return currency1;
japod@49
    27
    }
japod@49
    28
            
japod@49
    29
    public String getCurrency2() {
japod@49
    30
        return currency2;
japod@49
    31
    }
japod@49
    32
japod@49
    33
    public Rate getRate(){
japod@49
    34
        return rate;
japod@49
    35
    }
japod@49
    36
japod@49
    37
}