Skip to content

Commit 2fb5438

Browse files
committed
JAVAMONEY-97: Merged singletons into Money in core package.
1 parent 3d0b069 commit 2fb5438

36 files changed

+319
-319
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@
146146
</developers>
147147

148148
<ciManagement>
149-
<system>Jenkins</system>
150-
<url>https://jsr354.ci.cloudbees.com/</url>
149+
<system>Travis CI</system>
150+
<url>https://travis-ci.org/JavaMoney/jsr354-ri</url>
151151
</ciManagement>
152152

153153
<mailingLists>

src/main/asciidoc/userguide.adoc

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ You can use the currency code to access currencies.
7575
[source,java]
7676
.Accessing currencies by currency code
7777
--------------------------------------------
78-
CurrencyUnit currencyCHF = MonetaryCurrencies.getCurrencyUnit("CHF");
79-
CurrencyUnit currencyUSD = MonetaryCurrencies.getCurrencyUnit("USD");
80-
CurrencyUnit currencyEUR = MonetaryCurrencies.getCurrencyUnit("EUR");
78+
CurrencyUnit currencyCHF = Monetary.getCurrencyUnit("CHF");
79+
CurrencyUnit currencyUSD = Monetary.getCurrencyUnit("USD");
80+
CurrencyUnit currencyEUR = Monetary.getCurrencyUnit("EUR");
8181
--------------------------------------------
8282

8383
Hereby all codes available in the underlying JDK are mapped by default.
@@ -98,9 +98,9 @@ Similarly to +java.util.Currency+ a +CurrencyUnit+ can be accessed using this +L
9898
[source,java]
9999
.Accessing currencies by Locale
100100
--------------------------------------------
101-
CurrencyUnit currencyCHF = MonetaryCurrencies.getCurrencyUnit(new Locale("", "SUI")); // Switzerland
102-
CurrencyUnit currencyUSD = MonetaryCurrencies.getCurrencyUnit(new Locale("", "USA")); // United States of America
103-
CurrencyUnit currencyEUR = MonetaryCurrencies.getCurrencyUnit(new Locale("", "GER")); // Germany
101+
CurrencyUnit currencyCHF = Monetary.getCurrencyUnit(new Locale("", "SUI")); // Switzerland
102+
CurrencyUnit currencyUSD = Monetary.getCurrencyUnit(new Locale("", "USA")); // United States of America
103+
CurrencyUnit currencyEUR = Monetary.getCurrencyUnit(new Locale("", "GER")); // Germany
104104
--------------------------------------------
105105

106106
Hereby all codes available in the underlying JDK are mapped by default.
@@ -112,7 +112,7 @@ Also all currently known currencies can be accessed:
112112
[source,java]
113113
.Accessing all currencies
114114
--------------------------------------------
115-
Collection<CurrencyUnit> allCurrencies = MonetaryCurrencies.getCurrencies();
115+
Collection<CurrencyUnit> allCurrencies = Monetary.getCurrencies();
116116
--------------------------------------------
117117

118118
Similarly to other access methods you can also explicitly specifiy the provider chain to be used. The _Moneta_
@@ -235,8 +235,8 @@ sublist, when the according code is requested, or a unspecified request is perfo
235235
CurrencyUnit unit = CurrencyUnitBuilder.of("FLS22").setDefaultFractionUnits(3).build();
236236
237237
// registering it
238-
MonetaryCurrencies.registerCurrency(unit);
239-
MonetaryCurrencies.registerCurrency(unit, Locale.MyCOUNTRY);
238+
Monetary.registerCurrency(unit);
239+
Monetary.registerCurrency(unit, Locale.MyCOUNTRY);
240240
--------------------------------------------
241241

242242
Fortunately +CurrencyUnitBuilder+ is also capable of registering a currency on creation, by just passing
@@ -256,8 +256,8 @@ Alternatively one may use the +MonetaryCurrencies+ static methods as follows:
256256
CurrencyUnit unit = new CurrencyUnitBuilder.of("FLS22").setDefaultFractionUnits(3).build();
257257
258258
// registering it
259-
MonetaryCurrencies.registerCurrency(unit);
260-
MonetaryCurrencies.registerCurrency(unit, Locale.MyCOUNTRY);
259+
Monetary.registerCurrency(unit);
260+
Monetary.registerCurrency(unit, Locale.MyCOUNTRY);
261261
--------------------------------------------
262262

263263
==== Provided Currencies
@@ -291,7 +291,7 @@ new instances of amounts. E.g. instances of +FastMoney+ can be created as follow
291291
[source,java]
292292
.Creating instances of +FastMoney+ using the +MonetaryAmounts+ singleton:
293293
--------------------------------------------
294-
FastMoney m = MonetaryAmounts.getAmountFactory(FastMoney.class).setCurrency("USD").setNumber(200.20).create();
294+
FastMoney m = Monetary.getAmountFactory(FastMoney.class).setCurrency("USD").setNumber(200.20).create();
295295
--------------------------------------------
296296

297297
Additionally _Moneta_ also supports static factory methods on the types directly. So the following code is equivalent:
@@ -307,7 +307,7 @@ Creation of +Money+ instances is similar:
307307
[source,java]
308308
.Creating instances of +Money+:
309309
--------------------------------------------
310-
Money m1 = MonetaryAmounts.getAmountFactory(Money.class).setCurrency("USD").setNumber(200.20).create();
310+
Money m1 = Monetary.getAmountFactory(Money.class).setCurrency("USD").setNumber(200.20).create();
311311
Money m2 = Money.of("USD", 200.20);
312312
--------------------------------------------
313313

@@ -329,7 +329,7 @@ Using the JSR's main API allows to achieve the same as follows:
329329
[source,java]
330330
.Creating instances of +Money+ configuring the +MathContext+ to be used, using the +MonetaryAmountFactory+.
331331
--------------------------------------------
332-
Money money = MonetaryAmounts.getAmountFactory(Money.class)
332+
Money money = Monetary.getAmountFactory(Money.class)
333333
.setCurrencyUnit("CHF").setNumber(200).
334334
,setContext(MonetaryContextBuilder.create().set(MathContext.DECIMAL128).build())
335335
.create();
@@ -488,7 +488,7 @@ M money1 = money1.add(M.of(EURO, 1234567.3444));
488488
money1 = money1.subtract(M.of(EURO, 232323));
489489
money1 = money1.multiply(3.4);
490490
money1 = money1.divide(5.456);
491-
money1 = money1.with(MonetaryRoundings.getRounding());
491+
money1 = money1.with(Monetary.getRounding());
492492
--------------------------------------------
493493

494494
All tests were executed on a notebook with an +Intel i7 2.6GHz+ processor with SSD.
@@ -526,7 +526,7 @@ the +RoundingQuery+ passed:
526526
[source,java]
527527
.Access and apply arithmetic rounding.
528528
--------------------------------------------
529-
MonetaryRounding rounding = MonetaryRoundings.getRounding(
529+
MonetaryRounding rounding = Monetary.getRounding(
530530
RoundingQueryBuilder.create().setScale(4).set(RoundingMode.HALF_UP).build());
531531
MonetaryAmount amt = ...;
532532
MonetaryAmount roundedAmount = amt.with(rounding);
@@ -540,9 +540,9 @@ based on the current amount instance to be rounded:
540540
[source,java]
541541
.Access and apply default rounding.
542542
--------------------------------------------
543-
MonetaryRounding rounding = MonetaryRoundings.getDefaultRounding();
543+
MonetaryRounding rounding = Monetary.getDefaultRounding();
544544
MonetaryAmount amt = ...;
545-
MonetaryAmount roundedAmount = amt.with(rounding); // implicitly uses MonetaryRoundings.getRounding(CurrencyUnit);
545+
MonetaryAmount roundedAmount = amt.with(rounding); // implicitly uses Monetary.getRounding(CurrencyUnit);
546546
--------------------------------------------
547547

548548
Also you can access the default rounding for a given +CurrencyUnit+. Be default this will return an arithmetic rounding
@@ -552,9 +552,9 @@ based on the currency's _default fraction digits_, but it may also return a non
552552
.Access and apply default currency rounding.
553553
--------------------------------------------
554554
CurrencyUnit currency = ...;
555-
MonetaryRounding rounding = MonetaryRoundings.getRounding(currency);
555+
MonetaryRounding rounding = Monetary.getRounding(currency);
556556
MonetaryAmount amt = ...;
557-
MonetaryAmount roundedAmount = amt.with(rounding); // implicitly uses MonetaryRoundings.getRounding(CurrencyUnit);
557+
MonetaryAmount roundedAmount = amt.with(rounding); // implicitly uses Monetary.getRounding(CurrencyUnit);
558558
--------------------------------------------
559559

560560
For Swiss Francs also a corresponding cash rounding is accessible. In Switzerland the smallest minor in cash are
@@ -564,7 +564,7 @@ For Swiss Francs also a corresponding cash rounding is accessible. In Switzerlan
564564
[source,java]
565565
.Access Swiss Francs Cash Rounding
566566
--------------------------------------------
567-
MonetaryRounding rounding = MonetaryRoundings.getRounding(MonetaryCurrencies.getCurrency("CHF"),
567+
MonetaryRounding rounding = Monetary.getRounding(Monetary.getCurrency("CHF"),
568568
RoundingQueryBuilder.create().set("cashRounding", true).build()
569569
);
570570
MonetaryAmount amt = ...;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* Implementation of {@link javax.money.CurrencyUnit} that allows to of new instances using a fluent API.
2525
* Instances created also can be added to the {@link org.javamoney.moneta.internal.ConfigurableCurrencyUnitProvider}
26-
* singleton, which publishes the instances, so they are visible from the {@link javax.money.MonetaryCurrencies}
26+
* singleton, which publishes the instances, so they are visible from the {@link javax.money.Monetary}
2727
* singleton.
2828
*/
2929
final class BuildableCurrencyUnit implements CurrencyUnit, Comparable<CurrencyUnit>, Serializable {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public CurrencyUnit build() {
143143
* @param register if {@code true} the instance created is published so it is accessible from
144144
* the {@code MonetaryCurrencies} singleton.
145145
* @return the new CurrencyUnit instance.
146-
* @see javax.money.MonetaryCurrencies#getCurrency(String, String...)
146+
* @see javax.money.Monetary#getCurrency(String, String...)
147147
*/
148148
public CurrencyUnit build(boolean register) {
149149
BuildableCurrencyUnit cu = new BuildableCurrencyUnit(this);
@@ -161,8 +161,8 @@ public CurrencyUnit build(boolean register) {
161161
* the {@code MonetaryCurrencies} singleton.
162162
* @param locale country Locale for making the currency for the given country.
163163
* @return the new CurrencyUnit instance.
164-
* @see javax.money.MonetaryCurrencies#getCurrency(String, String...)
165-
* @see javax.money.MonetaryCurrencies#getCurrency(java.util.Locale, String...)
164+
* @see javax.money.Monetary#getCurrency(String, String...)
165+
* @see javax.money.Monetary#getCurrency(java.util.Locale, String...)
166166
*/
167167
public CurrencyUnit build(boolean register, Locale locale) {
168168
BuildableCurrencyUnit cu = new BuildableCurrencyUnit(this);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ public final class FastMoney implements MonetaryAmount, Comparable<MonetaryAmoun
113113
/**
114114
* Maximum possible value supported, using XX (no currency).
115115
*/
116-
public static final FastMoney MAX_VALUE = new FastMoney(Long.MAX_VALUE, MonetaryCurrencies.getCurrency("XXX"));
116+
public static final FastMoney MAX_VALUE = new FastMoney(Long.MAX_VALUE, Monetary.getCurrency("XXX"));
117117
/**
118118
* Maximum possible numeric value supported.
119119
*/
120120
private static final BigDecimal MAX_BD = MAX_VALUE.getBigDecimal();
121121
/**
122122
* Minimum possible value supported, using XX (no currency).
123123
*/
124-
public static final FastMoney MIN_VALUE = new FastMoney(Long.MIN_VALUE, MonetaryCurrencies.getCurrency("XXX"));
124+
public static final FastMoney MIN_VALUE = new FastMoney(Long.MIN_VALUE, Monetary.getCurrency("XXX"));
125125
/**
126126
* Minimum possible numeric value supported.
127127
*/
@@ -234,7 +234,7 @@ public static FastMoney of(Number number, CurrencyUnit currency) {
234234
* @return A new instance of {@link FastMoney}.
235235
*/
236236
public static FastMoney of(Number number, String currencyCode) {
237-
CurrencyUnit currency = MonetaryCurrencies.getCurrency(currencyCode);
237+
CurrencyUnit currency = Monetary.getCurrency(currencyCode);
238238
return of(number, currency);
239239
}
240240

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import javax.money.MonetaryAmount;
2626
import javax.money.MonetaryAmountFactory;
2727
import javax.money.MonetaryContext;
28-
import javax.money.MonetaryCurrencies;
28+
import javax.money.Monetary;
2929
import javax.money.MonetaryException;
3030
import javax.money.MonetaryOperator;
3131
import javax.money.MonetaryQuery;
@@ -753,7 +753,7 @@ public static Money of(Number number, CurrencyUnit currency, MonetaryContext mon
753753
* @return A new instance of {@link Money}.
754754
*/
755755
public static Money of(Number number, String currencyCode) {
756-
return new Money(MoneyUtils.getBigDecimal(number), MonetaryCurrencies.getCurrency(currencyCode));
756+
return new Money(MoneyUtils.getBigDecimal(number), Monetary.getCurrency(currencyCode));
757757
}
758758

759759
/**
@@ -764,7 +764,7 @@ public static Money of(Number number, String currencyCode) {
764764
* @return A new instance of {@link Money}.
765765
*/
766766
public static Money of(BigDecimal number, String currencyCode) {
767-
return new Money(number, MonetaryCurrencies.getCurrency(currencyCode));
767+
return new Money(number, Monetary.getCurrency(currencyCode));
768768
}
769769

770770
/**
@@ -777,7 +777,7 @@ public static Money of(BigDecimal number, String currencyCode) {
777777
* @return A new instance of {@link Money}.
778778
*/
779779
public static Money of(Number number, String currencyCode, MonetaryContext monetaryContext) {
780-
return new Money(MoneyUtils.getBigDecimal(number), MonetaryCurrencies.getCurrency(currencyCode),
780+
return new Money(MoneyUtils.getBigDecimal(number), Monetary.getCurrency(currencyCode),
781781
monetaryContext);
782782
}
783783

@@ -791,7 +791,7 @@ public static Money of(Number number, String currencyCode, MonetaryContext monet
791791
* @return A new instance of {@link Money}.
792792
*/
793793
public static Money of(BigDecimal number, String currencyCode, MonetaryContext monetaryContext) {
794-
return new Money(number, MonetaryCurrencies.getCurrency(currencyCode), monetaryContext);
794+
return new Money(number, Monetary.getCurrency(currencyCode), monetaryContext);
795795
}
796796

797797
/**

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public final class RoundedMoney implements MonetaryAmount, Comparable<MonetaryAm
5252
* The default {@link MonetaryContext} applied.
5353
*/
5454
public static final MonetaryContext DEFAULT_MONETARY_CONTEXT = MonetaryContextBuilder.of(RoundedMoney.class)
55-
.set("MonetaryRounding", MonetaryRoundings.getDefaultRounding()).
55+
.set("MonetaryRounding", Monetary.getDefaultRounding()).
5656
build();
5757

5858
/**
@@ -89,7 +89,7 @@ public RoundedMoney(Number number, CurrencyUnit currency, MonetaryOperator round
8989
public RoundedMoney(Number number, CurrencyUnit currency, MathContext mathContext) {
9090
Objects.requireNonNull(currency, "Currency is required.");
9191
this.currency = currency;
92-
this.rounding = MonetaryRoundings.getRounding(RoundingQueryBuilder.of().set(mathContext).build());
92+
this.rounding = Monetary.getRounding(RoundingQueryBuilder.of().set(mathContext).build());
9393
this.monetaryContext =
9494
DEFAULT_MONETARY_CONTEXT.toBuilder().set("MonetaryRounding", rounding).set(mathContext)
9595
.build();
@@ -116,17 +116,17 @@ public RoundedMoney(Number number, CurrencyUnit currency, MonetaryContext contex
116116
Integer scale = Optional.ofNullable(context.getInt("scale")).orElse(2);
117117
b.set(rm);
118118
b.set("scale", scale);
119-
this.rounding = MonetaryRoundings
119+
this.rounding = Monetary
120120
.getRounding(RoundingQueryBuilder.of().setScale(scale).set(rm).build());
121121
}
122122
} else {
123123
b.set(mc.getRoundingMode());
124124
b.set("scale", 2);
125125
this.rounding =
126-
MonetaryRoundings.getRounding(RoundingQueryBuilder.of().set(mc).setScale(2).build());
126+
Monetary.getRounding(RoundingQueryBuilder.of().set(mc).setScale(2).build());
127127
}
128128
if (this.rounding == null) {
129-
this.rounding = MonetaryRoundings.getDefaultRounding();
129+
this.rounding = Monetary.getDefaultRounding();
130130
}
131131
}
132132
}
@@ -149,7 +149,7 @@ public RoundedMoney(Number number, CurrencyUnit currency, MonetaryContext contex
149149
* @return a {@code Money} combining the numeric value and currency unit.
150150
*/
151151
public static RoundedMoney of(BigDecimal number, CurrencyUnit currency) {
152-
return new RoundedMoney(number, currency, MonetaryRoundings.getDefaultRounding());
152+
return new RoundedMoney(number, currency, Monetary.getDefaultRounding());
153153
}
154154

155155
/**
@@ -236,8 +236,8 @@ public static RoundedMoney of(CurrencyUnit currency, Number number, MonetaryCont
236236
* @return A new instance of {@link RoundedMoney}.
237237
*/
238238
public static RoundedMoney of(Number number, String currencyCode) {
239-
return new RoundedMoney(number, MonetaryCurrencies.getCurrency(currencyCode),
240-
MonetaryRoundings.getDefaultRounding());
239+
return new RoundedMoney(number, Monetary.getCurrency(currencyCode),
240+
Monetary.getDefaultRounding());
241241
}
242242

243243
/**
@@ -249,7 +249,7 @@ public static RoundedMoney of(Number number, String currencyCode) {
249249
* @return A new instance of {@link RoundedMoney}.
250250
*/
251251
public static RoundedMoney of(Number number, String currencyCode, MonetaryOperator rounding) {
252-
return new RoundedMoney(number, MonetaryCurrencies.getCurrency(currencyCode), rounding);
252+
return new RoundedMoney(number, Monetary.getCurrency(currencyCode), rounding);
253253
}
254254

255255
/**
@@ -260,7 +260,7 @@ public static RoundedMoney of(Number number, String currencyCode, MonetaryOperat
260260
* @return A new instance of {@link RoundedMoney}.
261261
*/
262262
public static RoundedMoney of(Number number, String currencyCode, MonetaryContext monetaryContext) {
263-
return new RoundedMoney(number, MonetaryCurrencies.getCurrency(currencyCode),
263+
return new RoundedMoney(number, Monetary.getCurrency(currencyCode),
264264
DEFAULT_MONETARY_CONTEXT.toBuilder().importContext(monetaryContext).build(), null);
265265
}
266266

@@ -274,7 +274,7 @@ public static RoundedMoney of(Number number, String currencyCode, MonetaryContex
274274
*/
275275
public static RoundedMoney of(String currencyCode, Number number, MonetaryContext monetaryContext,
276276
MonetaryOperator rounding) {
277-
return new RoundedMoney(number, MonetaryCurrencies.getCurrency(currencyCode),
277+
return new RoundedMoney(number, Monetary.getCurrency(currencyCode),
278278
DEFAULT_MONETARY_CONTEXT.toBuilder().importContext(monetaryContext).build(), rounding);
279279
}
280280

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import javax.money.CurrencyUnit;
99
import javax.money.MonetaryAmount;
10-
import javax.money.MonetaryCurrencies;
10+
import javax.money.Monetary;
1111
import javax.money.format.AmountFormatContext;
1212
import javax.money.format.MonetaryAmountFormat;
1313
import javax.money.format.MonetaryParseException;
@@ -61,7 +61,7 @@ public MonetaryAmount parse(CharSequence text)
6161

6262
private ParserMonetaryAmount parserMonetaryAmount(CharSequence text) {
6363
String[] array = Objects.requireNonNull(text).toString().split(" ");
64-
CurrencyUnit currencyUnit = MonetaryCurrencies.getCurrency(array[0]);
64+
CurrencyUnit currencyUnit = Monetary.getCurrency(array[0]);
6565
BigDecimal number = new BigDecimal(array[1]);
6666
return new ParserMonetaryAmount(currencyUnit, number);
6767
}

src/main/java/org/javamoney/moneta/function/MajorPart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
final class MajorPart implements MonetaryOperator {
2828

2929
private static final MonetaryRounding downRounding =
30-
MonetaryRoundings.getRounding(RoundingQueryBuilder.of().setScale(0).set(RoundingMode.DOWN).build());
30+
Monetary.getRounding(RoundingQueryBuilder.of().setScale(0).set(RoundingMode.DOWN).build());
3131

3232
/**
3333
* Access the shared instance of {@link MajorPart} for use.

src/main/java/org/javamoney/moneta/function/MajorUnits.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
final class MajorUnits implements MonetaryQuery<Long> {
3030

3131
private MonetaryOperator downRounding =
32-
MonetaryRoundings.getRounding(RoundingQueryBuilder.of().setScale(0).set(RoundingMode.DOWN).build());
32+
Monetary.getRounding(RoundingQueryBuilder.of().setScale(0).set(RoundingMode.DOWN).build());
3333

3434
/**
3535
* Access the shared instance of {@link MajorUnits} for use.

0 commit comments

Comments
 (0)