Skip to content

Commit abc808b

Browse files
committed
Fixed tests and bugs.
1 parent ee81af4 commit abc808b

File tree

13 files changed

+739
-730
lines changed

13 files changed

+739
-730
lines changed

src/main/java/org/javamoney/moneta/BuildableCurrencyUnit.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ final class BuildableCurrencyUnit implements CurrencyUnit, Comparable<CurrencyUn
3131
/**
3232
* serialVersionUID.
3333
*/
34-
private static final long serialVersionUID = -2389580389919492220L;
35-
/**
34+
private static final long serialVersionUID = -2389580389919492220L;
35+
/**
3636
* The unique currency code.
3737
*/
3838
private String currencyCode;
@@ -54,15 +54,15 @@ final class BuildableCurrencyUnit implements CurrencyUnit, Comparable<CurrencyUn
5454
*
5555
* @param builder the builder, never null.
5656
*/
57-
BuildableCurrencyUnit(CurrencyUnitBuilder builder){
57+
BuildableCurrencyUnit(CurrencyUnitBuilder builder) {
5858
Objects.requireNonNull(builder.currencyCode, "currencyCode required");
59-
if(builder.numericCode < -1){
59+
if (builder.numericCode < -1) {
6060
throw new MonetaryException("numericCode must be >= -1");
6161
}
62-
if(builder.defaultFractionDigits < 0){
62+
if (builder.defaultFractionDigits < 0) {
6363
throw new MonetaryException("defaultFractionDigits must be >= 0");
6464
}
65-
if(builder.currencyContext == null){
65+
if (builder.currencyContext == null) {
6666
throw new MonetaryException("currencyContext must be != null");
6767
}
6868
this.defaultFractionDigits = builder.defaultFractionDigits;
@@ -72,61 +72,61 @@ final class BuildableCurrencyUnit implements CurrencyUnit, Comparable<CurrencyUn
7272
}
7373

7474
@Override
75-
public String getCurrencyCode(){
75+
public String getCurrencyCode() {
7676
return currencyCode;
7777
}
7878

7979
@Override
80-
public int getNumericCode(){
80+
public int getNumericCode() {
8181
return numericCode;
8282
}
8383

8484
@Override
85-
public int getDefaultFractionDigits(){
85+
public int getDefaultFractionDigits() {
8686
return defaultFractionDigits;
8787
}
8888

8989
@Override
90-
public CurrencyContext getCurrencyContext(){
90+
public CurrencyContext getCurrencyContext() {
9191
return currencyContext;
9292
}
9393

9494
@Override
95-
public int compareTo(CurrencyUnit o){
96-
Objects.requireNonNull(o);
95+
public int compareTo(CurrencyUnit o) {
96+
Objects.requireNonNull(o);
9797
return this.currencyCode.compareTo(o.getCurrencyCode());
9898
}
9999

100100
/* (non-Javadoc)
101101
* @see java.lang.Object#hashCode()
102102
*/
103103
@Override
104-
public int hashCode(){
104+
public int hashCode() {
105105
return Objects.hashCode(currencyCode);
106106
}
107107

108108
/* (non-Javadoc)
109109
* @see java.lang.Object#equals(java.lang.Object)
110110
*/
111111
@Override
112-
public boolean equals(Object obj) {
113-
if (obj == this) {
112+
public boolean equals(Object obj) {
113+
if (obj == this) {
114114
return true;
115115
}
116-
if (obj instanceof BuildableCurrencyUnit) {
117-
BuildableCurrencyUnit other = (BuildableCurrencyUnit) obj;
118-
return Objects.equals(currencyCode, other.currencyCode);
119-
}
120-
return false;
116+
if (obj instanceof BuildableCurrencyUnit) {
117+
BuildableCurrencyUnit other = (BuildableCurrencyUnit) obj;
118+
return Objects.equals(currencyCode, other.currencyCode);
119+
}
120+
return false;
121121
}
122122

123123
/* (non-Javadoc)
124124
* @see java.lang.Object#toString()
125125
*/
126126
@Override
127-
public String toString(){
127+
public String toString() {
128128
return "BuildableCurrencyUnit(currencyCode=" + currencyCode + ", numericCode=" + numericCode +
129-
", defaultFractionDigits=" + defaultFractionDigits + ", context="+this.currencyContext+ ')';
129+
", defaultFractionDigits=" + defaultFractionDigits + ", context=" + this.currencyContext + ')';
130130
}
131131

132132

src/main/java/org/javamoney/moneta/DefaultExchangeRate.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
* href="https://en.wikipedia.org/wiki/Exchange_rate#Quotations">Wikipedia:
8282
* Exchange Rate (Quotations)</a>
8383
*/
84-
class DefaultExchangeRate implements ExchangeRate, Serializable, Comparable<ExchangeRate>{
84+
class DefaultExchangeRate implements ExchangeRate, Serializable, Comparable<ExchangeRate> {
8585

8686
/**
8787
* serialVersionUID.
@@ -115,7 +115,7 @@ class DefaultExchangeRate implements ExchangeRate, Serializable, Comparable<Exch
115115
*
116116
* @param builder The Builder, never {@code null}.
117117
*/
118-
DefaultExchangeRate(ExchangeRateBuilder builder){
118+
DefaultExchangeRate(ExchangeRateBuilder builder) {
119119
Objects.requireNonNull(builder.base, "base may not be null.");
120120
Objects.requireNonNull(builder.term, "term may not be null.");
121121
Objects.requireNonNull(builder.factor, "factor may not be null.");
@@ -134,13 +134,13 @@ class DefaultExchangeRate implements ExchangeRate, Serializable, Comparable<Exch
134134
*
135135
* @param chain the chain to set.
136136
*/
137-
private void setExchangeRateChain(List<ExchangeRate> chain){
137+
private void setExchangeRateChain(List<ExchangeRate> chain) {
138138
this.chain.clear();
139-
if(Objects.isNull(chain) || chain.isEmpty()){
139+
if (Objects.isNull(chain) || chain.isEmpty()) {
140140
this.chain.add(this);
141-
}else{
142-
for(ExchangeRate rate : chain){
143-
if(Objects.isNull(rate)){
141+
} else {
142+
for (ExchangeRate rate : chain) {
143+
if (Objects.isNull(rate)) {
144144
throw new IllegalArgumentException("Rate Chain element can not be null.");
145145
}
146146
}
@@ -153,7 +153,7 @@ private void setExchangeRateChain(List<ExchangeRate> chain){
153153
*
154154
* @return the conversion context, never null.
155155
*/
156-
public final ConversionContext getConversionContext(){
156+
public final ConversionContext getConversionContext() {
157157
return this.conversionContext;
158158
}
159159

@@ -162,7 +162,7 @@ public final ConversionContext getConversionContext(){
162162
*
163163
* @return the base {@link javax.money.CurrencyUnit}.
164164
*/
165-
public final CurrencyUnit getBaseCurrency(){
165+
public final CurrencyUnit getBaseCurrency() {
166166
return this.base;
167167
}
168168

@@ -171,7 +171,7 @@ public final CurrencyUnit getBaseCurrency(){
171171
*
172172
* @return the term {@link javax.money.CurrencyUnit}.
173173
*/
174-
public final CurrencyUnit getCurrency(){
174+
public final CurrencyUnit getCurrency() {
175175
return this.term;
176176
}
177177

@@ -180,7 +180,7 @@ public final CurrencyUnit getCurrency(){
180180
*
181181
* @return the bid factor for this exchange rate, or {@code null}.
182182
*/
183-
public final NumberValue getFactor(){
183+
public final NumberValue getFactor() {
184184
return this.factor;
185185
}
186186

@@ -191,7 +191,7 @@ public final NumberValue getFactor(){
191191
* several instances. For a direct exchange rate, this equals to
192192
* <code>new ExchangeRate[]{this}</code>.
193193
*/
194-
public final List<ExchangeRate> getExchangeRateChain(){
194+
public final List<ExchangeRate> getExchangeRateChain() {
195195
return this.chain;
196196
}
197197

@@ -207,7 +207,7 @@ public final List<ExchangeRate> getExchangeRateChain(){
207207
*
208208
* @return true, if the exchange rate is derived.
209209
*/
210-
public final boolean isDerived(){
210+
public final boolean isDerived() {
211211
return this.chain.size() > 1;
212212
}
213213

@@ -217,13 +217,13 @@ public final boolean isDerived(){
217217
* @see java.lang.Comparable#compareTo(java.lang.Object)
218218
*/
219219
@Override
220-
public int compareTo(ExchangeRate o){
220+
public int compareTo(ExchangeRate o) {
221221
Objects.requireNonNull(o);
222222
int compare = this.getBaseCurrency().getCurrencyCode().compareTo(o.getBaseCurrency().getCurrencyCode());
223-
if(compare == 0){
223+
if (compare == 0) {
224224
compare = this.getCurrency().getCurrencyCode().compareTo(o.getCurrency().getCurrencyCode());
225225
}
226-
if(compare == 0){
226+
if (compare == 0) {
227227
compare = this.getConversionContext().getProvider().compareTo(o.getConversionContext().getProvider());
228228
}
229229
return compare;
@@ -235,7 +235,7 @@ public int compareTo(ExchangeRate o){
235235
* @see java.lang.Object#toString()
236236
*/
237237
@Override
238-
public String toString(){
238+
public String toString() {
239239
return "ExchangeRate [base=" + base + ", factor=" + factor + ", conversionContext=" + conversionContext + ']';
240240
}
241241

@@ -245,7 +245,7 @@ public String toString(){
245245
* @see java.lang.Object#hashCode()
246246
*/
247247
@Override
248-
public int hashCode(){
248+
public int hashCode() {
249249
return Objects.hash(base, conversionContext, factor, term, chain);
250250
}
251251

@@ -255,11 +255,11 @@ public int hashCode(){
255255
* @see java.lang.Object#equals(java.lang.Object)
256256
*/
257257
@Override
258-
public boolean equals(Object obj){
259-
if(obj == this){
258+
public boolean equals(Object obj) {
259+
if (obj == this) {
260260
return true;
261261
}
262-
if(obj instanceof DefaultExchangeRate){
262+
if (obj instanceof DefaultExchangeRate) {
263263
DefaultExchangeRate other = (DefaultExchangeRate) obj;
264264
return Objects.equals(base, other.base) && Objects.equals(chain, other.chain) &&
265265
Objects.equals(conversionContext, other.conversionContext) &&
@@ -273,7 +273,7 @@ public boolean equals(Object obj){
273273
*
274274
* @return a new {@link ExchangeRateBuilder}, never {@code null}.
275275
*/
276-
public ExchangeRateBuilder toBuilder(){
276+
public ExchangeRateBuilder toBuilder() {
277277
return new ExchangeRateBuilder(getConversionContext()).setBase(getBaseCurrency()).setTerm(getCurrency())
278278
.setFactor(getFactor()).setRateChain(getExchangeRateChain());
279279
}

src/main/java/org/javamoney/moneta/FastMoney.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public FastMoney multiply(Number multiplicand) {
364364
if (isOne(multiplicand)) {
365365
return this;
366366
}
367-
return new FastMoney(Math.multiplyExact(this.number, getInternalNumber(multiplicand, false)),
367+
return new FastMoney(Math.multiplyExact(this.number, getInternalNumber(multiplicand, false)) / 100000L,
368368
getCurrency());
369369
}
370370

0 commit comments

Comments
 (0)