Skip to content

Commit 3353b30

Browse files
committed
JAVAMONEY-91: renamed getXXXContext() to getContext().
1 parent cdfb95c commit 3353b30

23 files changed

+115
-115
lines changed

src/main/asciidoc/JavaMoneySpecification.adoc

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,41 +2686,44 @@ customized logging Handler instances, so alternate logging backends can be used
26862686
The implementation that implements the API’s SPI may use a different logging approach.
26872687
26882688
2689-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2690-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2691-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2692-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2693-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2694-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2695-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2696-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2697-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2698-
2699-
27002689
[[MetadataModeling]]
2701-
== Meta-Data Modeling ==
2690+
== Meta-Data Contexts and Query Models ==
27022691
=== Overview ===
27032692
2704-
The JSR uses a unified meta-data model to support also more advanced use cases, which are not explicitly specified.
2693+
The JSR uses a unified meta-data model to support more advanced use cases, which are not explicitly specified.
27052694
Mostly reasons for not specifying these aspects is that these things are highly use case and organization dependent
27062695
aspects. In general there are 2 flavors of meta-data used throughout the JSR:
27072696
27082697
. _Contexts_ provide additional information on value types or services, such as currencies, amounts, conversions or
27092698
formats. Contexts are accessible directly from the corresponding value types, by calling methods named
2710-
+getXXXContext()+.
2711-
. _Queries_ models a generic and flexible way to configure services, such as currencies, amounts, conversions or formats
2712-
as needed. Queries can be passed to the different accessor singletons, and also are forwarded to the SPI
2699+
+getContext()+.
2700+
. _Queries_ models a generic and flexible way to configure/parametrize services for accessing currencies, amounts,
2701+
conversions or formats. Queries can be passed to the different accessor singletons, and also are forwarded to the SPI
27132702
implementations effectively providing the data/services required.
27142703
27152704
Similarly there are two abstract base classes provided:
27162705
27172706
. +AbstractContext+ models an abstract base type, which is extended by all context implementations within this JSR,
27182707
such as +MonetaryContext, CurrencyContext, RoundingContext, ProviderContext, ConversionContext, AmountFormatContext+.
2719-
. +AbstractQuery+ models an abstract base type, which is extended by all query implementations within this JSR,
2708+
. +AbstractQuery+ models an abstract base query, which is extended by all query implementations within this JSR,
27202709
such as +MonetaryAmountFactoryQuery, CurrencyQuery, RoundingQuery, ConversionQuery, AmountFormatQuery+.
27212710
27222711
The following sections give further information on these concepts.
27232712
2713+
2714+
2715+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2716+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2717+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2718+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2719+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2720+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2721+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2722+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2723+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2724+
2725+
2726+
27242727
[[AbstractContext]]
27252728
=== AbstractContext ===
27262729
@@ -2737,9 +2740,8 @@ implements Serializable{
27372740
...
27382741
public String getProviderName();
27392742
public Long getTimestampMillis();
2740-
public TemporalAccessor getTimestamp();
2743+
public LocalDateTime getTimestamp();
27412744

2742-
public boolean isEmpty();
27432745
public Boolean getBoolean(String key);
27442746
public Integer getInt(String key);
27452747
public Long getLong(String key);
@@ -2748,19 +2750,23 @@ implements Serializable{
27482750
public String getText(String key);
27492751
public <T> T get(Class<T> type);
27502752
public <T> T get(String key, Class<T> type);
2753+
2754+
public boolean isEmpty();
2755+
public Class<?> getType(String key);
27512756
public Set<String> getKeys(Class<?> type)
2752-
public <T> Map<String,T> getValues(Class<T> type)
27532757
}
27542758
-------------------------------------------------------------------------------
27552759
27562760
Hereby
27572761
27582762
* each context instance is related to a provider, that created the context, accessible from +getProviderName()+.
2759-
* each context instance can have an (optional) timestamp.
2763+
* each context instance can have an (optional) timestamp, e.g. usable for historic data.
27602764
* additional attributes can be set, which models a type safe interface for adding properties, without
27612765
duplicating artifacts or creating non portable dependencies.
27622766
** identified by the attribute’s type.
27632767
** identified an arbitrary literal key
2768+
* the +getXXX, get+ methods only return values of the resulting type is assignment compatible, so no class cast
2769+
exceptions do occur.
27642770
27652771
The classes extending this class hereby are thread-safe and immutable:
27662772
@@ -2797,26 +2803,20 @@ public abstract class AbstractContextBuilder<B extends AbstractContextBuilder, C
27972803
implements Serializable{
27982804
public B setProviderName(String provider);
27992805
public B setTimestampMillis(long timestamp);
2800-
public B setTimestamp(TemporalAccessor timestamp);
2806+
public B setTimestamp(LocalDateTime timestamp);
28012807

28022808
public B set(Object value);
28032809
public <T> B set(T value, Class<? extends T> type);
28042810
public B set(String key, Object value);
28052811
public <T> B set(String key, T value, Class<? extends T> type)
2806-
public B set(int value);
28072812
public B set(String key, int value);
2808-
public B set(long value);
28092813
public B set(String key, long value);
2810-
public B set(float value);
28112814
public B set(String key, float value);
2812-
public B set(double value);
28132815
public B set(String key, double value);
2814-
public B set(String key, String value);
28152816

28162817
public B importContext(AbstractContext context, boolean overwriteDuplicates);
28172818
public B importContext(AbstractContext context);
2818-
public B removeAttributes(Class<?> type, String... keys);
2819-
public B removeAll(Class<?> type);
2819+
public B removeAttributes(String... keys);
28202820

28212821
public abstract C build();
28222822

src/main/java/javax/money/CurrencyContextBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* <p>
1919
* Note this class is NOT thread-safe.
2020
*
21-
* @see javax.money.CurrencyUnit#getCurrencyContext()
21+
* @see javax.money.CurrencyUnit#getContext()
2222
*/
2323
public final class CurrencyContextBuilder extends AbstractContextBuilder<CurrencyContextBuilder, CurrencyContext> {
2424

src/main/java/javax/money/CurrencyUnit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ public interface CurrencyUnit extends Comparable<CurrencyUnit>{
9595
* on the type and capabilities of a CurrencyUnit, e.g. its provider and more.
9696
* @return the currency's context, never null.
9797
*/
98-
CurrencyContext getCurrencyContext();
98+
CurrencyContext getContext();
9999

100100
}

src/main/java/javax/money/MonetaryAmount.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public interface MonetaryAmount extends CurrencySupplier, NumberSupplier, Compar
104104
*
105105
* @return the {@link MonetaryContext} of this {@code MonetaryAmount}, never {@code null} .
106106
*/
107-
MonetaryContext getMonetaryContext();
107+
MonetaryContext getContext();
108108

109109
/**
110110
* Queries this monetary amount for a value.

src/main/java/javax/money/MonetaryAmountFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ default MonetaryAmountFactory<T> setCurrency(String currencyCode) {
143143
*
144144
* @param amount the amount to be used, not {@code null}.
145145
* @return this factory instance, for chaining.
146-
* @throws MonetaryException when the {@link MonetaryContext} implied by {@code amount.getMonetaryContext()}
146+
* @throws MonetaryException when the {@link MonetaryContext} implied by {@code amount.getContext()}
147147
* exceeds the capabilities supported by this factory type.
148148
*/
149149
default MonetaryAmountFactory<T> setAmount(MonetaryAmount amount) {
150150
setCurrency(amount.getCurrency());
151151
setNumber(amount.getNumber());
152-
setContext(amount.getMonetaryContext());
152+
setContext(amount.getContext());
153153
return this;
154154
}
155155

src/main/java/javax/money/MonetaryContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public int getMaxScale() {
103103
* Get the MonetaryAmount implementation class.
104104
*
105105
* @return the implementation class of the containing amount instance, never null.
106-
* @see MonetaryAmount#getMonetaryContext()
106+
* @see MonetaryAmount#getContext()
107107
*/
108108
public Class<? extends MonetaryAmount> getAmountType() {
109109
Class<?> clazz = get(AMOUNT_TYPE, Class.class);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* <p>
1616
* Note this class is NOT thread-safe.
1717
*
18-
* @see javax.money.MonetaryAmount#getMonetaryContext()
18+
* @see javax.money.MonetaryAmount#getContext()
1919
*/
2020
public final class MonetaryContextBuilder extends AbstractContextBuilder<MonetaryContextBuilder, MonetaryContext> {
2121

@@ -69,7 +69,7 @@ public MonetaryContextBuilder setFixedScale(boolean fixedScale) {
6969
* Set the MonetaryAmount implementation class.
7070
*
7171
* @return the implementation class of the containing amount instance, never null.
72-
* @see javax.money.MonetaryAmount#getMonetaryContext()
72+
* @see javax.money.MonetaryAmount#getContext()
7373
*/
7474
public MonetaryContextBuilder setAmountType(Class<? extends MonetaryAmount> amountType) {
7575
return set(MonetaryContext.AMOUNT_TYPE, amountType);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface CurrencyConversion extends MonetaryOperator, CurrencySupplier {
4646
*
4747
* @return the target {@link ConversionContext}.
4848
*/
49-
ConversionContext getConversionContext();
49+
ConversionContext getContext();
5050

5151
/**
5252
* Get the {@link ExchangeRate} applied for the given {@link MonetaryAmount}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
* <ul>
7777
* <li>must be Comparable(with {@code ExchangeRate})</li>
7878
* <li>must implement equals/hashCode considering #getBaseCurrency, #getCurrency,
79-
* #getFactor and #getConversionContext.</li>
79+
* #getFactor and #getContext.</li>
8080
* <li>should be thread-safe</li>
8181
* <li>should be serializable</li>
8282
* <li>should provide a fluent builder API for constructing new rate instances easily.</li>
@@ -96,7 +96,7 @@ public interface ExchangeRate extends CurrencySupplier {
9696
*
9797
* @return the conversion context, never null.
9898
*/
99-
ConversionContext getConversionContext();
99+
ConversionContext getContext();
100100

101101
/**
102102
* Get the base (source) {@link CurrencyUnit}.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface ExchangeRateProvider{
4646
*
4747
* @return the exchange rate type, never {@code null}.
4848
*/
49-
ProviderContext getProviderContext();
49+
ProviderContext getContext();
5050

5151
/**
5252
* Access a {@link ExchangeRate} using the given currencies. The
@@ -88,7 +88,7 @@ default boolean isAvailable(ConversionQuery conversionQuery){
8888
Objects.requireNonNull(conversionQuery);
8989
try{
9090
return conversionQuery.getProviderNames().isEmpty() ||
91-
conversionQuery.getProviderNames().contains(getProviderContext().getProviderName());
91+
conversionQuery.getProviderNames().contains(getContext().getProviderName());
9292
}
9393
catch(Exception e){
9494
return false;
@@ -182,7 +182,7 @@ default ExchangeRate getExchangeRate(String baseCode, String termCode){
182182
* the rate cannot be reversed.
183183
*/
184184
default ExchangeRate getReversed(ExchangeRate rate){
185-
ConversionQuery reverseQuery = rate.getConversionContext().toQueryBuilder().setBaseCurrency(rate.getCurrency())
185+
ConversionQuery reverseQuery = rate.getContext().toQueryBuilder().setBaseCurrency(rate.getCurrency())
186186
.setTermCurrency(rate.getBaseCurrency()).build();
187187
if(isAvailable(reverseQuery)){
188188
return getExchangeRate(reverseQuery);

0 commit comments

Comments
 (0)