Skip to content

Commit 81163a6

Browse files
committed
Unified getCurrency/setCurrency method names. Adapted to this change.
1 parent c19031d commit 81163a6

23 files changed

+369
-369
lines changed

src/main/java/javax/money/CurrencyQuery.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ public final class CurrencyQuery extends AbstractQuery implements Serializable{
3333
/**
3434
* Key for storing a countries to be queried.
3535
*/
36-
public static final String KEY_QUERY_COUNTRIES = "Query.countries";
36+
static final String KEY_QUERY_COUNTRIES = "Query.countries";
3737

3838
/**
3939
* Key for storing a target literal currency codes to be queried.
4040
*/
41-
public static final String KEY_QUERY_CURRENCY_CODES = "Query.currencyCodes";
41+
static final String KEY_QUERY_CURRENCY_CODES = "Query.currencyCodes";
4242

4343
/**
4444
* Key for storing a target numeric currency codes to be queried.
4545
*/
46-
public static final String KEY_QUERY_NUMERIC_CODES = "Query.numericCodes";
46+
static final String KEY_QUERY_NUMERIC_CODES = "Query.numericCodes";
4747

4848
/**
4949
* Constructor, used from the Builder.

src/main/java/javax/money/MonetaryAmountFactoryQuery.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public final class MonetaryAmountFactoryQuery extends AbstractQuery implements S
3030
/**
3131
* Key name for the context.
3232
*/
33-
public static final String KEY_PRECISION = "precision";
33+
static final String KEY_PRECISION = "precision";
3434

3535
/**
3636
* Key name for the currency provider.
3737
*/
38-
public static final String KEY_FIXED_SCALE = "fixedScale";
38+
static final String KEY_FIXED_SCALE = "fixedScale";
3939

4040
/**
4141
* Key name for the max scale.
4242
*/
43-
public static final String KEY_MAX_SCALE = "maxScale";
43+
static final String KEY_MAX_SCALE = "maxScale";
4444

4545
/**
4646
* Constructor, used from the {@link javax.money.MonetaryAmountFactoryQueryBuilder}.

src/main/java/javax/money/RoundingContext.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
*
2727
* @author Anatole Tresch
2828
*/
29-
public final class RoundingContext extends AbstractContext implements Serializable{
30-
/** Attribute key used for the rounding name. */
31-
public static final String KEY_ROUNDING_NAME = "roundingName";
29+
public final class RoundingContext extends AbstractContext implements Serializable, CurrencySupplier{
30+
/**
31+
* Attribute key used for the rounding name.
32+
*/
33+
static final String KEY_ROUNDING_NAME = "roundingName";
3234

3335
/**
3436
* Constructor, used from the {@link javax.money.RoundingContextBuilder}.
@@ -53,7 +55,7 @@ public String getRoundingName(){
5355
*
5456
* @return the target CurrencyUnit, or null.
5557
*/
56-
public CurrencyUnit getCurrencyUnit(){
58+
public CurrencyUnit getCurrency(){
5759
return get(CurrencyUnit.class, (CurrencyUnit) null);
5860
}
5961

src/main/java/javax/money/RoundingContextBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private RoundingContextBuilder(RoundingContext roundingContext){
4949
*
5050
* @return the target CurrencyUnit, or null.
5151
*/
52-
public RoundingContextBuilder setCurrencyUnit(CurrencyUnit currencyUnit){
52+
public RoundingContextBuilder setCurrency(CurrencyUnit currencyUnit){
5353
Objects.requireNonNull(currencyUnit);
5454
return set(currencyUnit, CurrencyUnit.class);
5555
}

src/main/java/javax/money/RoundingQuery.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424
* <p>
2525
* This class is immutable, thread-safe and serializable.
2626
*/
27-
public final class RoundingQuery extends AbstractQuery{
27+
public final class RoundingQuery extends AbstractQuery implements CurrencySupplier{
2828

29-
/** Attribute key used for the rounding name attribute. */
30-
public static final String KEY_QUERY_ROUNDING_NAME = "Query.roundingName";
29+
/**
30+
* Attribute key used for the rounding name attribute.
31+
*/
32+
static final String KEY_QUERY_ROUNDING_NAME = "Query.roundingName";
3133

32-
/** Attribute key used for the scale attribute. */
33-
public static final String KEY_QUERY_SCALE = "Query.scale";
34+
/**
35+
* Attribute key used for the scale attribute.
36+
*/
37+
static final String KEY_QUERY_SCALE = "Query.scale";
3438

3539
/**
3640
* Constructor, used from the {@link javax.money.RoundingQueryBuilder}.
@@ -64,15 +68,16 @@ public Integer getScale(){
6468
return getInt(KEY_QUERY_SCALE, null);
6569
}
6670

71+
6772
/**
68-
* Sets the target CurrencyUnit. Typically this determines all other properties,
69-
* such as scale and the concrete rounding algorithm. With
73+
* Returns the target CurrencyUnit, or null.
74+
* Typically this determines all other properties, such as scale and the concrete rounding algorithm. With
7075
* rounding names, depending on the implementation, additional sub-selections are possible. Similarly
7176
* additional attributes can be used to select special rounding instances, e.g. for cash rounding.
7277
*
7378
* @return the CurrencyUnit, or null.
7479
*/
75-
public CurrencyUnit getCurrencyUnit(){
80+
public CurrencyUnit getCurrency(){
7681
return get(CurrencyUnit.class, (CurrencyUnit) null);
7782
}
7883

src/main/java/javax/money/RoundingQueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public RoundingQueryBuilder setScale(int scale){
7171
* @param currencyUnit the target {@link CurrencyUnit} not null.
7272
* @return this instance for chaining
7373
*/
74-
public RoundingQueryBuilder setCurrencyUnit(CurrencyUnit currencyUnit){
74+
public RoundingQueryBuilder setCurrency(CurrencyUnit currencyUnit){
7575
Objects.requireNonNull(currencyUnit);
7676
set(CurrencyUnit.class, currencyUnit, CurrencyUnit.class);
7777
return this;

src/main/java/javax/money/convert/ConversionQuery.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package javax.money.convert;
99

1010
import javax.money.AbstractQuery;
11+
import javax.money.CurrencySupplier;
1112
import javax.money.CurrencyUnit;
1213
import java.util.*;
1314

@@ -16,19 +17,27 @@
1617
* should returns the <i>default</i> currencies.<p/>
1718
* This class is immutable, serializable and thread-safe.
1819
*/
19-
public final class ConversionQuery extends AbstractQuery{
20-
/** serialVersionUID. */
21-
private static final long serialVersionUID = -9147265628185601586L;
20+
public final class ConversionQuery extends AbstractQuery implements CurrencySupplier{
21+
/**
22+
* serialVersionUID.
23+
*/
24+
private static final long serialVersionUID = -9147265628185601586L;
2225

2326

24-
/** THe key used for the base currency attribute. */
25-
public static final String KEY_BASE_CURRENCY = "Query.baseCurrency";
27+
/**
28+
* THe key used for the base currency attribute.
29+
*/
30+
static final String KEY_BASE_CURRENCY = "Query.baseCurrency";
2631

27-
/** THe key used for the term currency attribute. */
28-
public static final String KEY_TERM_CURRENCY = "Query.termCurrency";
32+
/**
33+
* THe key used for the term currency attribute.
34+
*/
35+
static final String KEY_TERM_CURRENCY = "Query.termCurrency";
2936

30-
/** THe key used for the rate types attribute. */
31-
public static final String KEY_RATE_TYPES = "Query.rateTypes";
37+
/**
38+
* THe key used for the rate types attribute.
39+
*/
40+
static final String KEY_RATE_TYPES = "Query.rateTypes";
3241

3342
/**
3443
* Constructor, used from the ConversionQueryBuilder.
@@ -68,7 +77,7 @@ public CurrencyUnit getBaseCurrency(){
6877
*
6978
* @return the terminating CurrencyUnit, or null.
7079
*/
71-
public CurrencyUnit getTermCurrency(){
80+
public CurrencyUnit getCurrency(){
7281
return getAny(KEY_TERM_CURRENCY, CurrencyUnit.class, null);
7382
}
7483

@@ -80,5 +89,5 @@ public CurrencyUnit getTermCurrency(){
8089
public ConversionQueryBuilder toBuilder(){
8190
return ConversionQueryBuilder.create(this);
8291
}
83-
92+
8493
}

src/main/java/javax/money/convert/CurrencyConversion.java

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
*/
99
package javax.money.convert;
1010

11-
import javax.money.CurrencyUnit;
12-
import javax.money.MonetaryAmount;
13-
import javax.money.MonetaryException;
14-
import javax.money.MonetaryOperator;
11+
import javax.money.*;
1512

1613
/**
1714
* This interface defines a {@link CurrencyConversion} that is converting a {@link MonetaryAmount} to another
@@ -30,39 +27,33 @@
3027
* MonetaryAmount amountInCHF = amount.with(conversion);
3128
* </pre>
3229
* <p>
30+
* The terminating {@link CurrencyUnit} of this conversion instance can be
31+
* accessed from {@code getCurrency()}, inherited from {@code CurrencySupplier}.
32+
* <p>
3333
* Instances of this class are required to be thread-safe, but it is not a
3434
* requirement that they are serializable. In a EE context they can be
3535
* implemented using contextual beans.
36-
*
36+
*
3737
* @author Anatole Tresch
3838
* @author Werner Keil
3939
*/
40-
public interface CurrencyConversion extends MonetaryOperator {
41-
42-
/**
43-
* Access the terminating {@link CurrencyUnit} of this conversion instance.
44-
*
45-
* @return the terminating {@link CurrencyUnit} , never {@code null}.
46-
*/
47-
CurrencyUnit getTermCurrency();
40+
public interface CurrencyConversion extends MonetaryOperator, CurrencySupplier{
4841

49-
/**
50-
* Access the target {@link ConversionContext} of this conversion instance.
51-
*
52-
* @return the target {@link ConversionContext}.
53-
*/
42+
/**
43+
* Access the target {@link ConversionContext} of this conversion instance.
44+
*
45+
* @return the target {@link ConversionContext}.
46+
*/
5447
ConversionContext getConversionContext();
5548

56-
/**
57-
* Get the {@link ExchangeRate} applied for the given {@link MonetaryAmount}
58-
* .
59-
*
60-
* @param sourceAmount
61-
* the amount to be converted.
62-
* @return the {@link ExchangeRate} applied.
63-
* @throws MonetaryException
64-
* if the amount can not be converted.
65-
*/
49+
/**
50+
* Get the {@link ExchangeRate} applied for the given {@link MonetaryAmount}
51+
* .
52+
*
53+
* @param sourceAmount the amount to be converted.
54+
* @return the {@link ExchangeRate} applied.
55+
* @throws MonetaryException if the amount can not be converted.
56+
*/
6657
ExchangeRate getExchangeRate(MonetaryAmount sourceAmount);
6758

6859
}

src/main/java/javax/money/convert/CurrencyConversionException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term,
111111
*
112112
* @return the currency at fault, may be null
113113
*/
114-
public CurrencyUnit getBase() {
115-
return base;
114+
public CurrencyUnit getBaseCurrency(){
115+
return base;
116116
}
117117

118118
/**
119119
* Gets the second currency at fault.
120120
*
121121
* @return the currency at fault, may be null
122122
*/
123-
public CurrencyUnit getTerm() {
124-
return term;
123+
public CurrencyUnit getTermCurrency(){
124+
return term;
125125
}
126126

127127
/**

src/main/java/javax/money/convert/ExchangeRate.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
package javax.money.convert;
1212

13+
import javax.money.CurrencySupplier;
1314
import javax.money.CurrencyUnit;
1415
import javax.money.NumberValue;
1516
import java.io.Serializable;
@@ -73,20 +74,22 @@
7374
* <h3>Implementation Specification</h3>
7475
* <p>Implementations of this interface
7576
* <ul>
76-
* <li>must be Comparable(with {@code ExchangeRate})</li>
77-
* <li>must implement equals/hashCode considering #getBase, #getTerm, #getFactor and #getConversionContext.</li>
78-
* <li>should be thread-safe</li>
79-
* <li>should be serializable</li>
80-
* <li>should provide a fluent builder API for constructing new rate instances easily.</li>
77+
* <li>must be Comparable(with {@code ExchangeRate})</li>
78+
* <li>must implement equals/hashCode considering #getBaseCurrency, #getCurrency,
79+
* #getFactor and #getConversionContext.</li>
80+
* <li>should be thread-safe</li>
81+
* <li>should be serializable</li>
82+
* <li>should provide a fluent builder API for constructing new rate instances easily.</li>
8183
* </ul>
8284
* </ul></p>
85+
*
8386
* @author Werner Keil
8487
* @author Anatole Tresch
8588
* @see <a
8689
* href="https://en.wikipedia.org/wiki/Exchange_rate#Quotations">Wikipedia:
8790
* Exchange Rate (Quotations)</a>
8891
*/
89-
public interface ExchangeRate{
92+
public interface ExchangeRate extends CurrencySupplier{
9093

9194
/**
9295
* Access the {@link ConversionContext} of {@link ExchangeRate}.
@@ -100,14 +103,15 @@ public interface ExchangeRate{
100103
*
101104
* @return the base {@link CurrencyUnit}.
102105
*/
103-
CurrencyUnit getBase();
106+
CurrencyUnit getBaseCurrency();
104107

105108
/**
106109
* Get the term (target) {@link CurrencyUnit}.
107110
*
108111
* @return the term {@link CurrencyUnit}.
109112
*/
110-
CurrencyUnit getTerm();
113+
@Override
114+
CurrencyUnit getCurrency();
111115

112116
/**
113117
* Access the rate's bid factor.
@@ -130,14 +134,14 @@ public interface ExchangeRate{
130134
* Derived exchange rates are defined by an ordered list of subconversions
131135
* with intermediate steps, whereas a direct conversion is possible in one
132136
* steps.
133-
* <p/>
137+
* <p>
134138
* This method always returns {@code true}, if the chain contains more than
135139
* one rate. Direct rates, have also a chain, but with exact one rate.
136140
*
137141
* @return true, if the exchange rate is derived.
138142
*/
139143
default boolean isDerived(){
140-
return getExchangeRateChain().size()>1;
144+
return getExchangeRateChain().size() > 1;
141145
}
142146

143147
}

0 commit comments

Comments
 (0)