Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit c0140ee

Browse files
committed
Update Release
1 parent 479e628 commit c0140ee

File tree

9 files changed

+95
-207
lines changed

9 files changed

+95
-207
lines changed

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<artifactId>moneta-bp</artifactId>
2020
<packaging>bundle</packaging>
21-
<version>1.4.1-SNAPSHOT</version>
21+
<version>1.4.1</version>
2222
<name>Moneta (JSR 354 RI) for Java 7</name>
2323

2424
<description>JSR 354 provides an API for representing, transporting, and performing comprehensive calculations with
@@ -53,7 +53,7 @@
5353

5454
<ciManagement>
5555
<system>Travis-CI</system>
56-
<url>https://travis-ci.org/JavaMoney/javamoney-moneta-bp</url>
56+
<url>https://travis-ci.org/JavaMoney/jsr354-ri-bp</url>
5757
</ciManagement>
5858

5959
<issueManagement>
@@ -62,10 +62,10 @@
6262
</issueManagement>
6363

6464
<scm>
65-
<connection>scm:git:https://github.com/JavaMoney/javamoney-moneta-bp.git</connection>
65+
<connection>scm:git:https://github.com/JavaMoney/jsr354-ri-bp.git</connection>
6666
<tag>master</tag>
67-
<developerConnection>scm:git:https://github.com/JavaMoney/javamoney-moneta-bp.git</developerConnection>
68-
<url>https://github.com/JavaMoney/javamoney-moneta-bp</url>
67+
<developerConnection>scm:git:https://github.com/JavaMoney/jsr354-ri-bp.git</developerConnection>
68+
<url>https://github.com/JavaMoney/jsr354-ri-bp</url>
6969
</scm>
7070

7171
<distributionManagement>

src/main/java/org/javamoney/moneta/convert/DefaultMonetaryConversionsSingletonSpi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2020, Anatole Tresch, Werner Keil and others by the @author tag.
2+
* Copyright (c) 2012, 2014, Credit Suisse (Anatole Tresch), Werner Keil and others by the @author tag.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy of

src/main/java/org/javamoney/moneta/convert/ECBHistoric90RateProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* The default date is yesterday or the most recent day of week. To uses exchange rate from a specific date, you can use this way:
3232
* <code>CurrencyUnit termCurrency = ...;</code>
3333
* <code>LocalDate localDate = ...;</code>
34-
* <code>ConversionQuery conversionQuery = ConversionQueryBuilder.of().setTermCurrency(euro).set(localDate).build();</code>v
34+
* <code>ConversionQuery conversionQuery = ConversionQueryBuilder.of().setTermCurrency(euro).setTimestamp(localDate).build();</code>v
3535
* <code>CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);</code>
3636
* <code>MonetaryAmount money = ...;</code>
3737
* <code>MonetaryAmount result = currencyConversion.apply(money);</code>

src/main/java/org/javamoney/moneta/internal/JDKObjects.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/main/java/org/javamoney/moneta/spi/MoneyUtils.java

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2012, 2020, Werner Keil, Otavio Santana and others by the @author tag.
2+
Copyright (c) 2012, 2014, Credit Suisse (Anatole Tresch), Werner Keil and others by the @author tag.
33
44
Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
use this file except in compliance with the License. You may obtain a copy of
@@ -15,22 +15,16 @@
1515
*/
1616
package org.javamoney.moneta.spi;
1717

18-
import org.javamoney.moneta.internal.JDKObjects;
19-
2018
import javax.money.CurrencyUnit;
2119
import javax.money.MonetaryAmount;
2220
import javax.money.MonetaryContext;
2321
import javax.money.MonetaryException;
24-
2522
import java.math.BigDecimal;
2623
import java.math.MathContext;
2724
import java.math.RoundingMode;
25+
import java.util.Objects;
2826
import java.util.logging.Logger;
2927

30-
import static java.math.RoundingMode.HALF_EVEN;
31-
import static java.util.Objects.requireNonNull;
32-
import static java.util.logging.Level.FINEST;
33-
3428
/**
3529
* Platform RI: This utility class simplifies implementing {@link MonetaryAmount},
3630
* by providing the common functionality. The different explicitly typed methods
@@ -40,17 +34,13 @@
4034
* implement {@link MonetaryAmount} directly.
4135
*
4236
* @author Anatole Tresch
43-
* @author Werner Keil
4437
*/
4538
public final class MoneyUtils {
46-
39+
/**
40+
* The logger used.
41+
*/
4742
private static final Logger LOG = Logger.getLogger(MoneyUtils.class.getName());
4843

49-
public static final String NBSP_STRING = "\u00A0";
50-
public static final String NNBSP_STRING = "\u202F";
51-
public static final char NBSP = NBSP_STRING.charAt(0);
52-
public static final char NNBSP = NNBSP_STRING.charAt(0);
53-
5444
private MoneyUtils() {
5545
}
5646

@@ -104,18 +94,13 @@ public static BigDecimal getBigDecimal(Number num) {
10494
* @return the corresponding {@link BigDecimal}
10595
*/
10696
public static BigDecimal getBigDecimal(Number num, MonetaryContext moneyContext) {
107-
BigDecimal bd = getBigDecimal(num);
108-
if (JDKObjects.nonNull(moneyContext)) {
109-
MathContext mc = getMathContext(moneyContext, HALF_EVEN);
97+
BigDecimal bd = getBigDecimal(num);
98+
if (moneyContext!=null) {
99+
MathContext mc = getMathContext(moneyContext, RoundingMode.HALF_EVEN);
110100
bd = new BigDecimal(bd.toString(), mc);
111-
int maxScale = moneyContext.getMaxScale();
112-
if (maxScale > 0) {
113-
if (bd.scale() > maxScale) {
114-
if (LOG.isLoggable(FINEST)) {
115-
LOG.log(FINEST, "The number scale is " + bd.scale() + " but Max Scale is " + maxScale);
116-
}
117-
bd = bd.setScale(maxScale, mc.getRoundingMode());
118-
}
101+
if (moneyContext.getMaxScale() > 0) {
102+
LOG.fine(String.format("Got Max Scale %s", moneyContext.getMaxScale()));
103+
bd = bd.setScale(moneyContext.getMaxScale(), mc.getRoundingMode());
119104
}
120105
}
121106
return bd;
@@ -131,12 +116,15 @@ public static BigDecimal getBigDecimal(Number num, MonetaryContext moneyContext)
131116
*/
132117
public static MathContext getMathContext(MonetaryContext monetaryContext, RoundingMode defaultMode) {
133118
MathContext ctx = monetaryContext.get(MathContext.class);
134-
if (JDKObjects.nonNull(ctx)) {
119+
if (ctx!=null) {
135120
return ctx;
136121
}
137122
RoundingMode roundingMode = monetaryContext.get(RoundingMode.class);
138123
if (roundingMode == null) {
139-
roundingMode = HALF_EVEN;
124+
roundingMode = defaultMode;
125+
}
126+
if (roundingMode == null) {
127+
roundingMode = RoundingMode.HALF_EVEN;
140128
}
141129
return new MathContext(monetaryContext.getPrecision(), roundingMode);
142130
}
@@ -151,9 +139,9 @@ public static MathContext getMathContext(MonetaryContext monetaryContext, Roundi
151139
* {@link CurrencyUnit#getCurrencyCode()}).
152140
*/
153141
public static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit currencyUnit) {
154-
requireNonNull(amount, "Amount must not be null.");
142+
Objects.requireNonNull(amount, "Amount must not be null.");
155143
final CurrencyUnit amountCurrency = amount.getCurrency();
156-
if (!currencyUnit.getCurrencyCode().equals(amountCurrency.getCurrencyCode())) {
144+
if (!(currencyUnit.getCurrencyCode().equals(amountCurrency.getCurrencyCode()))) {
157145
throw new MonetaryException("Currency mismatch: " + currencyUnit + '/' + amountCurrency);
158146
}
159147
}
@@ -165,14 +153,7 @@ public static void checkAmountParameter(MonetaryAmount amount, CurrencyUnit curr
165153
* @throws IllegalArgumentException If the number is null
166154
*/
167155
public static void checkNumberParameter(Number number) {
168-
requireNonNull(number, "Number is required.");
156+
Objects.requireNonNull(number, "Number is required.");
169157
}
170158

171-
/**
172-
* Replaces the non-breaking space character U+00A0 and Narrow non-breaking space U+202F from the string with usual space.
173-
* https://en.wikipedia.org/wiki/Non-breaking_space}
174-
*/
175-
public static String replaceNbspWithSpace(String s) {
176-
return s.replace(NBSP, ' ').replace(NNBSP, ' ');
177-
}
178159
}

0 commit comments

Comments
 (0)