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