Skip to content

Commit e7cdccb

Browse files
committed
Quality fixes and additional Javadocs added.
1 parent 87f0ce0 commit e7cdccb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+223
-250
lines changed

src/main/java/javax/money/AbstractContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Set<String> getKeys(Class<?> type) {
6363

6464
/**
6565
* Get the current attribute type.
66-
*
66+
* @param key the entry's key, not null
6767
* @return the current attribute type, or null, if no such attribute exists.
6868
*/
6969
public Class<?> getType(String key) {
@@ -135,6 +135,7 @@ public Integer getInt(String key) {
135135
* @param key the attribute's key, not null.
136136
* @return the value, or null.
137137
*/
138+
@SuppressWarnings("BooleanMethodNameMustStartWithQuestion")
138139
public Boolean getBoolean(String key) {
139140
return get(key, Boolean.class);
140141
}

src/main/java/javax/money/AbstractQuery.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ public abstract class AbstractQuery extends AbstractContext {
2424
/**
2525
* Key for storing the target providers to be queried
2626
*/
27-
public static final String KEY_QUERY_PROVIDERS = "Query.providers";
27+
protected static final String KEY_QUERY_PROVIDERS = "Query.providers";
2828

2929
/**
3030
* Key name for the timestamp attribute.
3131
*/
32-
public static final String KEY_QUERY_TIMESTAMP = "Query.timestamp";
32+
protected static final String KEY_QUERY_TIMESTAMP = "Query.timestamp";
3333

3434
/**
3535
* Key name for the target type attribute.
3636
*/
37-
public static final String KEY_QUERY_TARGET_TYPE = "Query.targetType";
37+
protected static final String KEY_QUERY_TARGET_TYPE = "Query.targetType";
3838

3939

4040
/**

src/main/java/javax/money/Monetary.java

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@
2222
* </ul>
2323
* <p>This class is thread-safe, final and serializable.</p>
2424
*
25-
* @see MonetaryAmounts#getAmountFactory(MonetaryAmountFactoryQuery)
25+
* @see Monetary#getAmountFactory(MonetaryAmountFactoryQuery)
2626
* @see MonetaryAmountFactory
2727
*/
2828
public final class MonetaryAmountFactoryQuery extends AbstractQuery implements Serializable {
2929

3030
/**
3131
* Key name for the context.
3232
*/
33-
static final String KEY_PRECISION = "precision";
33+
private static final String KEY_PRECISION = "precision";
3434

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

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

4545
/**
4646
* Constructor, used from the {@link MonetaryAmountFactoryQueryBuilder}.
@@ -75,7 +75,7 @@ public Integer getPrecision() {
7575
*
7676
* @return the fixed scale flag, or null, if this attribute must not be considered.
7777
*/
78-
public Boolean getFixedScale() {
78+
public Boolean isFixedScale() {
7979
return getBoolean(KEY_FIXED_SCALE);
8080
}
8181

src/main/java/javax/money/MonetaryAmountFactoryQueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* <p>
1717
* Note this class is NOT thread-safe.
1818
*
19-
* @see javax.money.MonetaryAmounts#getAmountFactory(MonetaryAmountFactoryQuery)
19+
* @see javax.money.Monetary#getAmountFactory(MonetaryAmountFactoryQuery)
2020
* @see MonetaryAmountFactory
2121
*/
2222
public final class MonetaryAmountFactoryQueryBuilder

src/main/java/javax/money/MonetaryContextBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private MonetaryContextBuilder(MonetaryContext monetaryContext) {
3030
*
3131
* @param amountType the target amount type, not null.
3232
*/
33-
MonetaryContextBuilder(Class<? extends MonetaryAmount> amountType) {
33+
private MonetaryContextBuilder(Class<? extends MonetaryAmount> amountType) {
3434
set(MonetaryContext.AMOUNT_TYPE, amountType);
3535
}
3636

src/main/java/javax/money/MonetaryOperator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
package javax.money;
1414

15-
import java.util.function.UnaryOperator;
1615

1716
/**
1817
* Represents an operation on a single {@link MonetaryAmount} that produces a

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public ConversionContextBuilder() {
7575

7676
/**
7777
* Creates a new {@link javax.money.convert.ConversionContextBuilder} instance.
78-
*
78+
* @param conversionContext the conversion context to be used to initialize the new builder instance, not null.
7979
* @return a new {@link javax.money.convert.ConversionContextBuilder} instance, never null.
8080
*/
8181
public static ConversionContextBuilder of(ConversionContext conversionContext) {

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

Lines changed: 111 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -10,139 +10,137 @@
1010
*/
1111
package javax.money.convert;
1212

13-
import java.util.Objects;
14-
1513
import javax.money.CurrencyUnit;
1614
import javax.money.MonetaryException;
15+
import java.util.Objects;
1716

1817
/**
1918
* Exception thrown when a monetary conversion operation fails.
20-
*
19+
*
2120
* @author Werner Keil
2221
* @author Stephen Colebourne
2322
* @author Anatole Tresch
2423
*/
2524
public class CurrencyConversionException extends MonetaryException {
2625

27-
/** Serialization lock. */
28-
private static final long serialVersionUID = -7743240650686883450L;
26+
/**
27+
* Serialization lock.
28+
*/
29+
private static final long serialVersionUID = -7743240650686883450L;
2930

30-
/** Base currency. */
31-
private CurrencyUnit base;
32-
/** Terminating currency. */
33-
private CurrencyUnit term;
34-
/** The acquired {@link ConversionContext}, may be null. */
35-
private ConversionContext conversionContext;
31+
/**
32+
* Base currency.
33+
*/
34+
private final CurrencyUnit base;
35+
/**
36+
* Terminating currency.
37+
*/
38+
private final CurrencyUnit term;
39+
/**
40+
* The acquired {@link ConversionContext}, may be null.
41+
*/
42+
private final ConversionContext conversionContext;
3643

37-
/**
38-
* Constructs an <code>CurrencyConversionException</code> with the specified
39-
* detail message, timestamp, source and target currency.
40-
*
41-
* @param base
42-
* the source currency, may be null.
43-
*
44-
* @param term
45-
* the target currency, may be null.
46-
*
47-
* @param message
48-
* the detail message.
49-
*/
50-
public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term,
51-
ConversionContext conversionContext, String message) {
52-
super("Cannot convert " + String.valueOf(base) + " into "
53-
+ String.valueOf(term) + ": " + message);
54-
this.base = base;
55-
this.term = term;
56-
this.conversionContext = conversionContext;
57-
}
44+
/**
45+
* Constructs an <code>CurrencyConversionException</code> with the specified
46+
* detail message, timestamp, source and target currency.
47+
*
48+
* @param base the source currency, may be null.
49+
* @param term the target currency, may be null.
50+
* @param conversionContext the {@link javax.money.convert.ConversionContext} in place.
51+
* @param message the detail message.
52+
*/
53+
public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term,
54+
ConversionContext conversionContext, String message) {
55+
super("Cannot convert " + String.valueOf(base) + " into "
56+
+ String.valueOf(term) + ": " + message);
57+
this.base = base;
58+
this.term = term;
59+
this.conversionContext = conversionContext;
60+
}
5861

59-
/**
60-
* Constructs an <code>CurrencyConversionException</code> with the specified
61-
* source and target currency.
62-
*
63-
* @param base
64-
* the source currency, may be null.
65-
*
66-
* @param term
67-
* the target currency, may be null.
68-
*/
69-
public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term,
70-
ConversionContext conversionContext) {
71-
super("Cannot convert " + String.valueOf(base) + " into "
72-
+ String.valueOf(term));
73-
this.base = base;
74-
this.term = term;
75-
this.conversionContext = conversionContext;
76-
}
62+
/**
63+
* Constructs an <code>CurrencyConversionException</code> with the specified
64+
* source and target currency.
65+
*
66+
* @param base the source currency, may be null.
67+
* @param term the target currency, may be null.
68+
* @param conversionContext the {@link javax.money.convert.ConversionContext} in place.
69+
*/
70+
public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term,
71+
ConversionContext conversionContext) {
72+
super("Cannot convert " + String.valueOf(base) + " into "
73+
+ String.valueOf(term));
74+
this.base = base;
75+
this.term = term;
76+
this.conversionContext = conversionContext;
77+
}
7778

78-
/**
79-
* Constructs a new exception with the specified source and target currency,
80-
* detail message and cause.
81-
*
82-
* <p>
83-
* Note that the detail message associated with <code>cause</code> is
84-
* <i>not</i> automatically incorporated in this exception's detail message.
85-
*
86-
* @param base
87-
* the source currency, may be null.
88-
* @param term
89-
* the target currency, may be null.
90-
* @param message
91-
* the detail message (which is saved for later retrieval by the
92-
* {@link Throwable#getMessage()} method).
93-
* @param cause
94-
* the cause (which is saved for later retrieval by the
95-
* {@link Throwable#getCause()} method). (A <tt>null</tt> value
96-
* is permitted, and indicates that the cause is nonexistent or
97-
* unknown.)
98-
*/
99-
public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term,
100-
ConversionContext conversionContext, String message, Throwable cause) {
101-
super("Cannot convert " + String.valueOf(base) + " into "
102-
+ String.valueOf(term)
103-
+ (Objects.nonNull(message) ? ": " + message : ""), cause);
104-
this.base = base;
105-
this.term = term;
106-
this.conversionContext = conversionContext;
107-
}
79+
/**
80+
* Constructs a new exception with the specified source and target currency,
81+
* detail message and cause.
82+
* <p/>
83+
* <p/>
84+
* Note that the detail message associated with <code>cause</code> is
85+
* <i>not</i> automatically incorporated in this exception's detail message.
86+
*
87+
* @param base the source currency, may be null.
88+
* @param term the target currency, may be null.
89+
* @param message the detail message (which is saved for later retrieval by the
90+
* {@link Throwable#getMessage()} method).
91+
* @param cause the cause (which is saved for later retrieval by the
92+
* {@link Throwable#getCause()} method). (A <tt>null</tt> value
93+
* is permitted, and indicates that the cause is nonexistent or
94+
* unknown.)
95+
* @param conversionContext the {@link javax.money.convert.ConversionContext} in place.
96+
*/
97+
public CurrencyConversionException(CurrencyUnit base, CurrencyUnit term,
98+
ConversionContext conversionContext, String message, Throwable cause) {
99+
super("Cannot convert " + String.valueOf(base) + " into "
100+
+ String.valueOf(term)
101+
+ (Objects.nonNull(message) ? ": " + message : ""), cause);
102+
this.base = base;
103+
this.term = term;
104+
this.conversionContext = conversionContext;
105+
}
108106

109-
/**
110-
* Gets the first currency at fault.
111-
*
112-
* @return the currency at fault, may be null
113-
*/
114-
public CurrencyUnit getBaseCurrency(){
107+
/**
108+
* Gets the first currency at fault.
109+
*
110+
* @return the currency at fault, may be null
111+
*/
112+
public CurrencyUnit getBaseCurrency() {
115113
return base;
116-
}
114+
}
117115

118-
/**
119-
* Gets the second currency at fault.
120-
*
121-
* @return the currency at fault, may be null
122-
*/
123-
public CurrencyUnit getTermCurrency(){
116+
/**
117+
* Gets the second currency at fault.
118+
*
119+
* @return the currency at fault, may be null
120+
*/
121+
public CurrencyUnit getTermCurrency() {
124122
return term;
125-
}
123+
}
126124

127-
/**
128-
* Gets the queried timestamp at fault.
129-
*
130-
* @return the queried timestamp, or {@code null}.
131-
*/
132-
public ConversionContext getConversionContext() {
133-
return this.conversionContext;
134-
}
125+
/**
126+
* Gets the queried timestamp at fault.
127+
*
128+
* @return the queried timestamp, or {@code null}.
129+
*/
130+
public ConversionContext getConversionContext() {
131+
return this.conversionContext;
132+
}
135133

136-
/*
137-
* (non-Javadoc)
138-
*
139-
* @see java.lang.Object#toString()
140-
*/
141-
@Override
142-
public String toString() {
143-
return "CurrencyConversionException [base=" + base + ", term=" + term
144-
+ ", conversionContext=" + conversionContext + "]: "
145-
+ getMessage();
146-
}
134+
/*
135+
* (non-Javadoc)
136+
*
137+
* @see java.lang.Object#toString()
138+
*/
139+
@Override
140+
public String toString() {
141+
return "CurrencyConversionException [base=" + base + ", term=" + term
142+
+ ", conversionContext=" + conversionContext + "]: "
143+
+ getMessage();
144+
}
147145

148146
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public ProviderContextBuilder setRateTypes(RateType... rateTypes) {
8787
@SuppressWarnings({"unchecked", "rawtypes"})
8888
public ProviderContextBuilder setRateTypes(Collection<RateType> rateTypes) {
8989
Objects.requireNonNull(rateTypes);
90-
if (rateTypes.size() == 0) {
90+
if (rateTypes.isEmpty()) {
9191
throw new IllegalArgumentException("At least one RateType is required.");
9292
}
9393
Set rtSet = new HashSet<>();

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public enum RateType{
3939
OTHER,
4040
/**
4141
* Any type of rates. This can be used, where any type of rate is suitable. This may be feasible if you
42-
* access a specific chain of rate providers, e.g. by calling {@link MonetaryConversions#getConversion(String,
43-
* ConversionContext, String...)},
42+
* access a specific chain of rate providers,
4443
* where the order of providers already implies a prioritization and the rate type in that scenario is not relevant.
4544
*/
4645
ANY

src/main/java/javax/money/format/AmountFormatQuery.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public MonetaryAmountFactory getMonetaryAmountFactory() {
8080
*
8181
* @param locale the target locale, not null.
8282
* @param providers the providers to be used, not null.
83+
* @return a new query instance
8384
*/
8485
public static AmountFormatQuery of(Locale locale, String... providers) {
8586
return AmountFormatQueryBuilder.of(locale).setProviderNames(providers).build();

0 commit comments

Comments
 (0)