|
10 | 10 | */ |
11 | 11 | package javax.money.convert; |
12 | 12 |
|
13 | | -import java.util.Objects; |
14 | | - |
15 | 13 | import javax.money.CurrencyUnit; |
16 | 14 | import javax.money.MonetaryException; |
| 15 | +import java.util.Objects; |
17 | 16 |
|
18 | 17 | /** |
19 | 18 | * Exception thrown when a monetary conversion operation fails. |
20 | | - * |
| 19 | + * |
21 | 20 | * @author Werner Keil |
22 | 21 | * @author Stephen Colebourne |
23 | 22 | * @author Anatole Tresch |
24 | 23 | */ |
25 | 24 | public class CurrencyConversionException extends MonetaryException { |
26 | 25 |
|
27 | | - /** Serialization lock. */ |
28 | | - private static final long serialVersionUID = -7743240650686883450L; |
| 26 | + /** |
| 27 | + * Serialization lock. |
| 28 | + */ |
| 29 | + private static final long serialVersionUID = -7743240650686883450L; |
29 | 30 |
|
30 | | - /** Base currency. */ |
31 | | - private CurrencyUnit base; |
32 | | - /** Terminating currency. */ |
33 | | - private CurrencyUnit term; |
34 | | - /** The acquired {@link ConversionContext}, may be null. */ |
35 | | - private ConversionContext conversionContext; |
| 31 | + /** |
| 32 | + * Base currency. |
| 33 | + */ |
| 34 | + private final CurrencyUnit base; |
| 35 | + /** |
| 36 | + * Terminating currency. |
| 37 | + */ |
| 38 | + private final CurrencyUnit term; |
| 39 | + /** |
| 40 | + * The acquired {@link ConversionContext}, may be null. |
| 41 | + */ |
| 42 | + private final ConversionContext conversionContext; |
36 | 43 |
|
37 | | - /** |
38 | | - * Constructs an <code>CurrencyConversionException</code> with the specified |
39 | | - * detail message, timestamp, source and target currency. |
40 | | - * |
41 | | - * @param base |
42 | | - * the source currency, may be null. |
43 | | - * |
44 | | - * @param term |
45 | | - * the target currency, may be null. |
46 | | - * |
47 | | - * @param message |
48 | | - * the detail message. |
49 | | - */ |
50 | | - public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term, |
51 | | - ConversionContext conversionContext, String message) { |
52 | | - super("Cannot convert " + String.valueOf(base) + " into " |
53 | | - + String.valueOf(term) + ": " + message); |
54 | | - this.base = base; |
55 | | - this.term = term; |
56 | | - this.conversionContext = conversionContext; |
57 | | - } |
| 44 | + /** |
| 45 | + * Constructs an <code>CurrencyConversionException</code> with the specified |
| 46 | + * detail message, timestamp, source and target currency. |
| 47 | + * |
| 48 | + * @param base the source currency, may be null. |
| 49 | + * @param term the target currency, may be null. |
| 50 | + * @param conversionContext the {@link javax.money.convert.ConversionContext} in place. |
| 51 | + * @param message the detail message. |
| 52 | + */ |
| 53 | + public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term, |
| 54 | + ConversionContext conversionContext, String message) { |
| 55 | + super("Cannot convert " + String.valueOf(base) + " into " |
| 56 | + + String.valueOf(term) + ": " + message); |
| 57 | + this.base = base; |
| 58 | + this.term = term; |
| 59 | + this.conversionContext = conversionContext; |
| 60 | + } |
58 | 61 |
|
59 | | - /** |
60 | | - * Constructs an <code>CurrencyConversionException</code> with the specified |
61 | | - * source and target currency. |
62 | | - * |
63 | | - * @param base |
64 | | - * the source currency, may be null. |
65 | | - * |
66 | | - * @param term |
67 | | - * the target currency, may be null. |
68 | | - */ |
69 | | - public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term, |
70 | | - ConversionContext conversionContext) { |
71 | | - super("Cannot convert " + String.valueOf(base) + " into " |
72 | | - + String.valueOf(term)); |
73 | | - this.base = base; |
74 | | - this.term = term; |
75 | | - this.conversionContext = conversionContext; |
76 | | - } |
| 62 | + /** |
| 63 | + * Constructs an <code>CurrencyConversionException</code> with the specified |
| 64 | + * source and target currency. |
| 65 | + * |
| 66 | + * @param base the source currency, may be null. |
| 67 | + * @param term the target currency, may be null. |
| 68 | + * @param conversionContext the {@link javax.money.convert.ConversionContext} in place. |
| 69 | + */ |
| 70 | + public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term, |
| 71 | + ConversionContext conversionContext) { |
| 72 | + super("Cannot convert " + String.valueOf(base) + " into " |
| 73 | + + String.valueOf(term)); |
| 74 | + this.base = base; |
| 75 | + this.term = term; |
| 76 | + this.conversionContext = conversionContext; |
| 77 | + } |
77 | 78 |
|
78 | | - /** |
79 | | - * Constructs a new exception with the specified source and target currency, |
80 | | - * detail message and cause. |
81 | | - * |
82 | | - * <p> |
83 | | - * Note that the detail message associated with <code>cause</code> is |
84 | | - * <i>not</i> automatically incorporated in this exception's detail message. |
85 | | - * |
86 | | - * @param base |
87 | | - * the source currency, may be null. |
88 | | - * @param term |
89 | | - * the target currency, may be null. |
90 | | - * @param message |
91 | | - * the detail message (which is saved for later retrieval by the |
92 | | - * {@link Throwable#getMessage()} method). |
93 | | - * @param cause |
94 | | - * the cause (which is saved for later retrieval by the |
95 | | - * {@link Throwable#getCause()} method). (A <tt>null</tt> value |
96 | | - * is permitted, and indicates that the cause is nonexistent or |
97 | | - * unknown.) |
98 | | - */ |
99 | | - public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term, |
100 | | - ConversionContext conversionContext, String message, Throwable cause) { |
101 | | - super("Cannot convert " + String.valueOf(base) + " into " |
102 | | - + String.valueOf(term) |
103 | | - + (Objects.nonNull(message) ? ": " + message : ""), cause); |
104 | | - this.base = base; |
105 | | - this.term = term; |
106 | | - this.conversionContext = conversionContext; |
107 | | - } |
| 79 | + /** |
| 80 | + * Constructs a new exception with the specified source and target currency, |
| 81 | + * detail message and cause. |
| 82 | + * <p/> |
| 83 | + * <p/> |
| 84 | + * Note that the detail message associated with <code>cause</code> is |
| 85 | + * <i>not</i> automatically incorporated in this exception's detail message. |
| 86 | + * |
| 87 | + * @param base the source currency, may be null. |
| 88 | + * @param term the target currency, may be null. |
| 89 | + * @param message the detail message (which is saved for later retrieval by the |
| 90 | + * {@link Throwable#getMessage()} method). |
| 91 | + * @param cause the cause (which is saved for later retrieval by the |
| 92 | + * {@link Throwable#getCause()} method). (A <tt>null</tt> value |
| 93 | + * is permitted, and indicates that the cause is nonexistent or |
| 94 | + * unknown.) |
| 95 | + * @param conversionContext the {@link javax.money.convert.ConversionContext} in place. |
| 96 | + */ |
| 97 | + public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term, |
| 98 | + ConversionContext conversionContext, String message, Throwable cause) { |
| 99 | + super("Cannot convert " + String.valueOf(base) + " into " |
| 100 | + + String.valueOf(term) |
| 101 | + + (Objects.nonNull(message) ? ": " + message : ""), cause); |
| 102 | + this.base = base; |
| 103 | + this.term = term; |
| 104 | + this.conversionContext = conversionContext; |
| 105 | + } |
108 | 106 |
|
109 | | - /** |
110 | | - * Gets the first currency at fault. |
111 | | - * |
112 | | - * @return the currency at fault, may be null |
113 | | - */ |
114 | | - public CurrencyUnit getBaseCurrency(){ |
| 107 | + /** |
| 108 | + * Gets the first currency at fault. |
| 109 | + * |
| 110 | + * @return the currency at fault, may be null |
| 111 | + */ |
| 112 | + public CurrencyUnit getBaseCurrency() { |
115 | 113 | return base; |
116 | | - } |
| 114 | + } |
117 | 115 |
|
118 | | - /** |
119 | | - * Gets the second currency at fault. |
120 | | - * |
121 | | - * @return the currency at fault, may be null |
122 | | - */ |
123 | | - public CurrencyUnit getTermCurrency(){ |
| 116 | + /** |
| 117 | + * Gets the second currency at fault. |
| 118 | + * |
| 119 | + * @return the currency at fault, may be null |
| 120 | + */ |
| 121 | + public CurrencyUnit getTermCurrency() { |
124 | 122 | return term; |
125 | | - } |
| 123 | + } |
126 | 124 |
|
127 | | - /** |
128 | | - * Gets the queried timestamp at fault. |
129 | | - * |
130 | | - * @return the queried timestamp, or {@code null}. |
131 | | - */ |
132 | | - public ConversionContext getConversionContext() { |
133 | | - return this.conversionContext; |
134 | | - } |
| 125 | + /** |
| 126 | + * Gets the queried timestamp at fault. |
| 127 | + * |
| 128 | + * @return the queried timestamp, or {@code null}. |
| 129 | + */ |
| 130 | + public ConversionContext getConversionContext() { |
| 131 | + return this.conversionContext; |
| 132 | + } |
135 | 133 |
|
136 | | - /* |
137 | | - * (non-Javadoc) |
138 | | - * |
139 | | - * @see java.lang.Object#toString() |
140 | | - */ |
141 | | - @Override |
142 | | - public String toString() { |
143 | | - return "CurrencyConversionException [base=" + base + ", term=" + term |
144 | | - + ", conversionContext=" + conversionContext + "]: " |
145 | | - + getMessage(); |
146 | | - } |
| 134 | + /* |
| 135 | + * (non-Javadoc) |
| 136 | + * |
| 137 | + * @see java.lang.Object#toString() |
| 138 | + */ |
| 139 | + @Override |
| 140 | + public String toString() { |
| 141 | + return "CurrencyConversionException [base=" + base + ", term=" + term |
| 142 | + + ", conversionContext=" + conversionContext + "]: " |
| 143 | + + getMessage(); |
| 144 | + } |
147 | 145 |
|
148 | 146 | } |
0 commit comments