5
5
* DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
6
6
* AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
7
7
* BUTTON AT THE BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency
8
- * API ("Specification") Copyright (c) 2012-2013 , Credit Suisse All rights
8
+ * API ("Specification") Copyright (c) 2012-2014 , Credit Suisse All rights
9
9
* reserved.
10
10
*/
11
11
package javax .money .convert ;
12
12
13
13
import java .io .Serializable ;
14
- import java .math .BigDecimal ;
15
14
import java .util .Arrays ;
16
15
import java .util .List ;
17
16
import java .util .Objects ;
18
17
19
18
import javax .money .CurrencyUnit ;
19
+ import javax .money .NumberValue ;
20
20
21
21
/**
22
22
* This class models an exchange rate between two currencies. Hereby
66
66
* <ul>
67
67
* <li>The base {@link CurrencyUnit}
68
68
* <li>The target {@link CurrencyUnit}
69
- * <li>The factor (BigDecimal )
69
+ * <li>The factor (NumberValue )
70
70
* <li>The {@link ConversionContext}
71
71
* <li>The rate chain
72
72
* </ul>
@@ -96,7 +96,7 @@ public final class ExchangeRate implements Serializable,
96
96
/**
97
97
* The conversion factor.
98
98
*/
99
- private final BigDecimal factor ;
99
+ private final NumberValue factor ;
100
100
/**
101
101
* The {@link ConversionContext}
102
102
*/
@@ -114,15 +114,15 @@ public final class ExchangeRate implements Serializable,
114
114
* the number
115
115
* @return a BigDecimal representing the number.
116
116
*/
117
- private BigDecimal getBigDecimal (Number num ) {
118
- if (num instanceof BigDecimal ) {
119
- return (BigDecimal ) num ;
120
- }
121
- if (num instanceof Long ) {
122
- return BigDecimal .valueOf (num .longValue ());
123
- }
124
- return BigDecimal .valueOf (num .doubleValue ());
125
- }
117
+ // private BigDecimal getBigDecimal(Number num) {
118
+ // if (num instanceof BigDecimal) {
119
+ // return (BigDecimal) num;
120
+ // }
121
+ // if (num instanceof Long) {
122
+ // return BigDecimal.valueOf(num.longValue());
123
+ // }
124
+ // return BigDecimal.valueOf(num.doubleValue());
125
+ // }
126
126
127
127
/**
128
128
* Creates a new instance with a custom chain of exchange rate type, e.g. or
@@ -153,7 +153,7 @@ private ExchangeRate(Builder builder) {
153
153
"exchangeRateType may not be null." );
154
154
this .base = builder .base ;
155
155
this .term = builder .term ;
156
- this .factor = getBigDecimal ( builder .factor ) ;
156
+ this .factor = builder .factor ;
157
157
this .conversionContext = builder .conversionContext ;
158
158
setExchangeRateChain (builder .rateChain );
159
159
}
@@ -211,7 +211,7 @@ public final CurrencyUnit getTerm() {
211
211
*
212
212
* @return the bid factor for this exchange rate, or {@code null}.
213
213
*/
214
- public final BigDecimal getFactor () {
214
+ public final NumberValue getFactor () {
215
215
return this .factor ;
216
216
}
217
217
@@ -373,7 +373,7 @@ public static class Builder {
373
373
/**
374
374
* The conversion factor.
375
375
*/
376
- private BigDecimal factor ;
376
+ private NumberValue factor ;
377
377
/**
378
378
* The chain of invovled rates.
379
379
*/
@@ -447,16 +447,12 @@ public Builder setRateChain(ExchangeRate... exchangeRates) {
447
447
* the factor.
448
448
* @return The builder instance.
449
449
*/
450
- public Builder setFactor (Number factor ) {
451
- if (factor != null ) {
452
- if (factor instanceof BigDecimal ) {
453
- this .factor = (BigDecimal ) factor ;
454
- } else {
455
- this .factor = BigDecimal .valueOf (factor .doubleValue ());
456
- }
457
- }
458
- return this ;
459
- }
450
+ // public Builder setFactor(Number factor) {
451
+ // if (factor != null) {
452
+ // this.factor = new DefaultNumberValue(factor);
453
+ // }
454
+ // return this;
455
+ // }
460
456
461
457
/**
462
458
* Sets the conversion factor, as the factor
@@ -466,7 +462,7 @@ public Builder setFactor(Number factor) {
466
462
* the factor.
467
463
* @return The builder instance.
468
464
*/
469
- public Builder setFactor (BigDecimal factor ) {
465
+ public Builder setFactor (NumberValue factor ) {
470
466
this .factor = factor ;
471
467
return this ;
472
468
}
0 commit comments