55 * DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
66 * AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
77 * 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
99 * reserved.
1010 */
1111package javax .money .convert ;
1212
1313import java .io .Serializable ;
14- import java .math .BigDecimal ;
1514import java .util .Arrays ;
1615import java .util .List ;
1716import java .util .Objects ;
1817
1918import javax .money .CurrencyUnit ;
19+ import javax .money .NumberValue ;
2020
2121/**
2222 * This class models an exchange rate between two currencies. Hereby
6666 * <ul>
6767 * <li>The base {@link CurrencyUnit}
6868 * <li>The target {@link CurrencyUnit}
69- * <li>The factor (BigDecimal )
69+ * <li>The factor (NumberValue )
7070 * <li>The {@link ConversionContext}
7171 * <li>The rate chain
7272 * </ul>
@@ -96,7 +96,7 @@ public final class ExchangeRate implements Serializable,
9696 /**
9797 * The conversion factor.
9898 */
99- private final BigDecimal factor ;
99+ private final NumberValue factor ;
100100 /**
101101 * The {@link ConversionContext}
102102 */
@@ -114,15 +114,15 @@ public final class ExchangeRate implements Serializable,
114114 * the number
115115 * @return a BigDecimal representing the number.
116116 */
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+ // }
126126
127127 /**
128128 * Creates a new instance with a custom chain of exchange rate type, e.g. or
@@ -153,7 +153,7 @@ private ExchangeRate(Builder builder) {
153153 "exchangeRateType may not be null." );
154154 this .base = builder .base ;
155155 this .term = builder .term ;
156- this .factor = getBigDecimal ( builder .factor ) ;
156+ this .factor = builder .factor ;
157157 this .conversionContext = builder .conversionContext ;
158158 setExchangeRateChain (builder .rateChain );
159159 }
@@ -211,7 +211,7 @@ public final CurrencyUnit getTerm() {
211211 *
212212 * @return the bid factor for this exchange rate, or {@code null}.
213213 */
214- public final BigDecimal getFactor () {
214+ public final NumberValue getFactor () {
215215 return this .factor ;
216216 }
217217
@@ -373,7 +373,7 @@ public static class Builder {
373373 /**
374374 * The conversion factor.
375375 */
376- private BigDecimal factor ;
376+ private NumberValue factor ;
377377 /**
378378 * The chain of invovled rates.
379379 */
@@ -447,16 +447,12 @@ public Builder setRateChain(ExchangeRate... exchangeRates) {
447447 * the factor.
448448 * @return The builder instance.
449449 */
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+ // }
460456
461457 /**
462458 * Sets the conversion factor, as the factor
@@ -466,7 +462,7 @@ public Builder setFactor(Number factor) {
466462 * the factor.
467463 * @return The builder instance.
468464 */
469- public Builder setFactor (BigDecimal factor ) {
465+ public Builder setFactor (NumberValue factor ) {
470466 this .factor = factor ;
471467 return this ;
472468 }
0 commit comments