task2/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 01 Oct 2008 10:43:05 +0200
changeset 29 f6073056b9fe
parent 17 task1/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java@37c9921c653e
child 35 8898c620fe96
permissions -rw-r--r--
Getting ready for task2: copying all solutions to new locations
     1 package org.apidesign.apifest08.currency;
     2 
     3       
     4 import java.util.Currency;
     5 
     6 
     7 /**
     8  * Thrown when a currency is invalid for a given Convertor.
     9  * 
    10  * @author D'Arcy Smith
    11  * @version 1.0
    12  */
    13 public class InvalidConversionException
    14     extends Exception
    15 {
    16     /**
    17      * The currency that was tried.
    18      */
    19     private final Currency badCurrency;
    20     
    21     /**
    22      * A currency that is valid for the Convertor.
    23      */
    24     private final Currency currencyA;
    25 
    26     /**
    27      * A currency that is valid for the Convertor.
    28      */
    29     private final Currency currencyB;
    30     
    31     /**
    32      * Construct a new InvalidConversionException wit the specified message.
    33      * 
    34      * @param msg the message for getMessage.
    35      * @param bad the currency that is not valid.
    36      * @param a a valid currency.
    37      * @param b a valid currency.
    38      */
    39     public InvalidConversionException(final String    msg,
    40                                        final Currency bad,
    41                                        final Currency a,
    42                                        final Currency b)
    43     {
    44         super(msg);
    45 
    46         badCurrency = bad;
    47         currencyA   = a;
    48         currencyB   = b;
    49     }
    50 
    51     /**
    52      * Get the currency that is not valid.
    53      * 
    54      * @return the badCurrency
    55      */
    56     public Currency getBadCurrency()
    57     {
    58         return (badCurrency);
    59     }
    60 
    61     /**
    62      * Get a currency that is valid.
    63      * 
    64      * @return the currencyA passed to the constructor.
    65      */
    66     public Currency getCurrencyA()
    67     {
    68         return (currencyA);
    69     }
    70 
    71     /**
    72      * Get a currency that is valid.
    73      * 
    74      * @return the currencyB passed to the constructor.
    75      */
    76     public Currency getCurrencyB()
    77     {
    78         return (currencyB);
    79     }
    80 
    81 
    82 }