17
17
*/
18
18
package org .javamoney .cdi .internal ;
19
19
20
- import org .javamoney .cdi .api . AmountSpec ;
21
- import org .javamoney .cdi .api . CurrencySpec ;
22
- import org .javamoney .cdi .api . FormatSpec ;
23
- import org .javamoney .cdi .api . ConversionSpec ;
20
+ import org .javamoney .cdi .Amount ;
21
+ import org .javamoney .cdi .AmountConversion ;
22
+ import org .javamoney .cdi .AmountCurrency ;
23
+ import org .javamoney .cdi .AmountFormat ;
24
24
25
25
import javax .enterprise .context .Dependent ;
26
26
import javax .enterprise .inject .Produces ;
@@ -49,11 +49,11 @@ private MonetaryProducer(){}
49
49
50
50
@ Produces @ Dependent
51
51
public static CurrencyUnit currencyUnit (InjectionPoint ip ){
52
- CurrencySpec specAnnot = ip .getAnnotated ()!=null ?
53
- ip .getAnnotated ().getAnnotation (CurrencySpec .class ):
52
+ AmountCurrency specAnnot = ip .getAnnotated ()!=null ?
53
+ ip .getAnnotated ().getAnnotation (AmountCurrency .class ):
54
54
null ;
55
55
if (specAnnot ==null ){
56
- Currency jdkDefault = Currency .getInstance (Locale .getDefault ());
56
+ java . util . Currency jdkDefault = java . util . Currency .getInstance (Locale .getDefault ());
57
57
if (jdkDefault !=null ) {
58
58
return Monetary .getCurrency (jdkDefault .getCurrencyCode ());
59
59
}else {
@@ -66,7 +66,7 @@ public static CurrencyUnit currencyUnit(InjectionPoint ip){
66
66
67
67
@ Produces @ Dependent
68
68
public static Collection <CurrencyUnit > currencyUnits (InjectionPoint ip ){
69
- CurrencySpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (CurrencySpec .class ):null ;
69
+ AmountCurrency specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountCurrency .class ):null ;
70
70
if (specAnnot !=null ){
71
71
return Monetary .getCurrencies (createCurrencyQuery (specAnnot ));
72
72
}
@@ -76,7 +76,7 @@ public static Collection<CurrencyUnit> currencyUnits(InjectionPoint ip){
76
76
77
77
@ Produces @ Dependent
78
78
public static ExchangeRateProvider rateProvider (InjectionPoint ip ){
79
- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
79
+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
80
80
if (specAnnot !=null ){
81
81
return MonetaryConversions .getExchangeRateProvider (createConversionQuery (specAnnot ));
82
82
}
@@ -86,7 +86,7 @@ public static ExchangeRateProvider rateProvider(InjectionPoint ip){
86
86
@ Produces @ Dependent
87
87
public static Collection <ExchangeRateProvider > rateProviders (InjectionPoint ip ){
88
88
List <ExchangeRateProvider > providers = new ArrayList <>();
89
- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
89
+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
90
90
if (specAnnot !=null && specAnnot .providers ().length >0 ){
91
91
for (String providerId :specAnnot .providers ()){
92
92
providers .add (MonetaryConversions .getExchangeRateProvider (providerId ));
@@ -102,7 +102,7 @@ public static Collection<ExchangeRateProvider> rateProviders(InjectionPoint ip){
102
102
103
103
@ Produces @ Dependent
104
104
public static CurrencyConversion currencyConversion (InjectionPoint ip ){
105
- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
105
+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
106
106
if (specAnnot ==null ){
107
107
throw new IllegalArgumentException ("@RateSpec is required." );
108
108
}
@@ -111,7 +111,7 @@ public static CurrencyConversion currencyConversion(InjectionPoint ip){
111
111
112
112
@ Produces @ Dependent
113
113
public static ExchangeRate exchangeRate (InjectionPoint ip ){
114
- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
114
+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
115
115
if (specAnnot ==null ){
116
116
throw new IllegalArgumentException ("@RateSpec is required." );
117
117
}
@@ -122,7 +122,7 @@ public static ExchangeRate exchangeRate(InjectionPoint ip){
122
122
123
123
@ Produces @ Dependent
124
124
public static Collection <ExchangeRate > exchangeRates (InjectionPoint ip ){
125
- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
125
+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
126
126
if (specAnnot ==null ){
127
127
throw new IllegalArgumentException ("@RateSpec is required." );
128
128
}
@@ -151,31 +151,31 @@ public static Collection<ExchangeRate> exchangeRates(InjectionPoint ip){
151
151
152
152
@ Produces @ Dependent
153
153
public static MonetaryAmountFormat amountFormat (InjectionPoint ip ){
154
- FormatSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (FormatSpec .class ):null ;
154
+ AmountFormat specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountFormat .class ):null ;
155
155
if (specAnnot ==null ){
156
156
throw new IllegalArgumentException ("@FormatName is required." );
157
157
}
158
158
return MonetaryFormats .getAmountFormat (createAmountFormatQuery (
159
159
specAnnot ,
160
- ip .getAnnotated ().getAnnotation (AmountSpec .class )));
160
+ ip .getAnnotated ().getAnnotation (Amount .class )));
161
161
}
162
162
163
163
164
164
@ Produces @ Dependent
165
165
public static Collection <MonetaryAmountFormat > amountFormats (InjectionPoint ip ){
166
- FormatSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (FormatSpec .class ):null ;
166
+ AmountFormat specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountFormat .class ):null ;
167
167
if (specAnnot ==null ){
168
168
throw new IllegalArgumentException ("@FormatName is required." );
169
169
}
170
170
return MonetaryFormats .getAmountFormats (createAmountFormatQuery (
171
171
specAnnot ,
172
- ip .getAnnotated ().getAnnotation (AmountSpec .class )));
172
+ ip .getAnnotated ().getAnnotation (Amount .class )));
173
173
}
174
174
175
175
176
176
@ Produces @ Dependent
177
177
public static MonetaryAmountFactory amountFactory (InjectionPoint ip ){
178
- AmountSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
178
+ Amount specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
179
179
if (specAnnot !=null ){
180
180
return Monetary .getAmountFactory (createAmountQuery (specAnnot ));
181
181
}
@@ -186,7 +186,7 @@ public static MonetaryAmountFactory amountFactory(InjectionPoint ip){
186
186
@ SuppressWarnings ("unchecked" )
187
187
@ Produces @ Dependent
188
188
public static Collection <MonetaryAmountFactory > amountFactories (InjectionPoint ip ){
189
- AmountSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
189
+ Amount specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
190
190
if (specAnnot !=null ){
191
191
return Collection .class .cast (Monetary .getAmountFactories (createAmountQuery (specAnnot )));
192
192
}
@@ -195,7 +195,7 @@ public static Collection<MonetaryAmountFactory> amountFactories(InjectionPoint i
195
195
196
196
@ Produces @ Dependent
197
197
public static CurrencyQuery currencyQuery (InjectionPoint ip ){
198
- CurrencySpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (CurrencySpec .class ):null ;
198
+ AmountCurrency specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountCurrency .class ):null ;
199
199
if (specAnnot ==null ){
200
200
return null ;
201
201
}
@@ -204,7 +204,7 @@ public static CurrencyQuery currencyQuery(InjectionPoint ip){
204
204
205
205
@ Produces @ Dependent
206
206
public static ConversionQuery conversionQuery (InjectionPoint ip ){
207
- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
207
+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
208
208
if (specAnnot ==null ){
209
209
return null ;
210
210
}
@@ -213,24 +213,24 @@ public static ConversionQuery conversionQuery(InjectionPoint ip){
213
213
214
214
@ Produces @ Dependent
215
215
public static AmountFormatQuery amountFormatQuery (InjectionPoint ip ){
216
- FormatSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (FormatSpec .class ):null ;
216
+ AmountFormat specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountFormat .class ):null ;
217
217
if (specAnnot ==null ){
218
218
return null ;
219
219
}
220
- AmountSpec amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
220
+ Amount amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
221
221
return createAmountFormatQuery (specAnnot , amountSpec );
222
222
}
223
223
224
224
@ Produces @ Dependent
225
225
public static MonetaryAmountFactoryQuery amountFactoryQuery (InjectionPoint ip ){
226
- AmountSpec amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
226
+ Amount amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
227
227
if (amountSpec ==null ){
228
228
return null ;
229
229
}
230
230
return createAmountQuery (amountSpec );
231
231
}
232
232
233
- private static CurrencyQuery createCurrencyQuery (CurrencySpec specAnnot ) {
233
+ private static CurrencyQuery createCurrencyQuery (AmountCurrency specAnnot ) {
234
234
CurrencyQueryBuilder b = CurrencyQueryBuilder .of ();
235
235
b .setCountries (convertToCountries (specAnnot .countries ()));
236
236
b .setCurrencyCodes (specAnnot .codes ());
@@ -252,7 +252,7 @@ private static Locale[] convertToCountries(String[] codes) {
252
252
return locales ;
253
253
}
254
254
255
- private static ConversionQuery createConversionQuery (ConversionSpec specAnnot ) {
255
+ private static ConversionQuery createConversionQuery (AmountConversion specAnnot ) {
256
256
ConversionQueryBuilder b = ConversionQueryBuilder .of ();
257
257
if (!specAnnot .baseCurrency ().isEmpty ()){
258
258
b .setBaseCurrency (specAnnot .baseCurrency ());
@@ -272,7 +272,7 @@ private static ConversionQuery createConversionQuery(ConversionSpec specAnnot) {
272
272
return b .build ();
273
273
}
274
274
275
- private static AmountFormatQuery createAmountFormatQuery (FormatSpec specAnnot , AmountSpec amountSpec ) {
275
+ private static AmountFormatQuery createAmountFormatQuery (AmountFormat specAnnot , Amount amountSpec ) {
276
276
AmountFormatQueryBuilder b = AmountFormatQueryBuilder .of (specAnnot .name ());
277
277
if (specAnnot .providers ().length >0 ){
278
278
b .setProviderNames (specAnnot .providers ());
@@ -304,7 +304,7 @@ private static Locale createLocale(String locale) {
304
304
}
305
305
}
306
306
307
- private static MonetaryAmountFactoryQuery createAmountQuery (AmountSpec specAnnot ) {
307
+ private static MonetaryAmountFactoryQuery createAmountQuery (Amount specAnnot ) {
308
308
MonetaryAmountFactoryQueryBuilder b = MonetaryAmountFactoryQueryBuilder .of ();
309
309
if (specAnnot .value ()!=MonetaryAmount .class ){
310
310
b .setTargetType (specAnnot .value ());
0 commit comments