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
     1 
     2 package org.apidesign.apifest08.currency;
     3 
     4 public final class CurrencyRateImpl implements CurrencyRate {
     5     private String currency1;
     6     private String currency2;
     7     private Rate rate;
     8     
     9     CurrencyRateImpl(final String currency1, final String currency2, final Rate rate) {
    10         if ((currency1 == null)||(currency2 == null) || (rate == null)) {
    11             throw new IllegalArgumentException("Argument cannot be null.");
    12         }
    13         if ("".equals(currency1) || "".equals(currency2)) {
    14             throw new IllegalArgumentException("Name of currency cannot be empty string");
    15         }
    16         if (currency1.equals(currency2)) {
    17             throw new IllegalArgumentException("Currencies in rate cannot be the same");
    18         }
    19        
    20         this.currency1 = currency1;
    21         this.currency2 = currency2;
    22         this.rate = rate;
    23     }
    24 
    25     public String getCurrency1() {
    26         return currency1;
    27     }
    28             
    29     public String getCurrency2() {
    30         return currency2;
    31     }
    32 
    33     public Rate getRate(){
    34         return rate;
    35     }
    36 
    37 }