task2/solution14/src/org/apidesign/apifest08/currency/CurrencyRateImpl.java
author japod@localhost
Wed, 08 Oct 2008 12:51:52 +0200
changeset 49 de033c457bed
permissions -rw-r--r--
adding solution14 for task2
     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 }